0
I am trying to make calculator but I couldn't
can you help me any one
10 Antworten
+ 1
Your using (**) instead of ("),
printf (**enter the first nuber :**);
printf ("enter the first nuber: ");
0
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
float num1;
flot num2;
char op;
float result;
printf (**enter the first nuber:**);
scanf (**%f**,&num1);
printf (**enter the opretion :**);
scanf (** %c**,&op);
printf (**enter the nuber**);
scanf (**%f**,&num2);
switch (op);
{
case '-':
result = num1-num2;
printf (**%**,result);
break;
case '+':
result = num1+num2;
printf (**%**,result);
break;
case '*':
result = num1*num2;
printf (**%**,result);
break;
case '/':
result = num1/num2;
printf (**%**,result);
break;
default
printf (use operator is not valid);
}
getch();
}
0
Thank you
0
Than how to submit
0
Compiling fetal
0
Plz help me
0
Make changes your as suggested then share updated code by saving in code and share link.. That will make easy to identify mistakes..
And you have lot of mistakes in syntaxes.. Apart from those,
canio.h is deprecated api, it won't work on modern compilers so remove that..
Clrscr() only work on windows, in PCs. so comment that..
Remove unnecessary spaces in print and scanf like just put
scanf("%c", &op);
Remove semicolon after
switch(op) //; remove this ;
Make int main()
getch() also don't work, so use getc() or getchar() ;
Make all these changes..
I suggest you to revise your learnings again ones...
Hope it helps you...
0
Okk
0
//corrected code : Input ex: 4*5
#include<stdio.h>
//#include<conio.h> it don't works here
int main()
{
//clrscr();
float num1;
float num2;
char op;
float result;
printf("enter the first nuber:**");
scanf("%f",&num1);
printf ("enter the opretion :");
scanf("%c",&op);
printf ("enter the nuber");
scanf("%f",&num2);
printf("\n%cc\n%f,%f\n",op,num1,num2);
switch (op)
{
case '-':
result = num1-num2;
printf ("%f",result);
break;
case '+':
result = num1+num2;
printf ("%f",result);
break;
case '*':
result = num1*num2;
printf ("%f",result);
break;
case '/':
result = num1/num2;
printf ("%f",result);
break;
default : //you missed colon :
printf ("use operator is not valid");
}
getchar();
return 0;
}