0

I am trying to make calculator but I couldn't

can you help me any one

10th Jul 2020, 6:33 PM
Pancham Das
Pancham Das - avatar
9 odpowiedzi
+ 1
Your using (**) instead of ("), printf (**enter the first nuber :**); printf ("enter the first nuber: ");
10th Jul 2020, 6:42 PM
rodwynnejones
rodwynnejones - avatar
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(); }
10th Jul 2020, 6:36 PM
Pancham Das
Pancham Das - avatar
0
Thank you
10th Jul 2020, 6:44 PM
Pancham Das
Pancham Das - avatar
0
Than how to submit
10th Jul 2020, 6:50 PM
Pancham Das
Pancham Das - avatar
0
Compiling fetal
10th Jul 2020, 6:58 PM
Pancham Das
Pancham Das - avatar
0
Plz help me
10th Jul 2020, 6:58 PM
Pancham Das
Pancham Das - avatar
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...
10th Jul 2020, 7:36 PM
Jayakrishna 🇮🇳
0
Okk
10th Jul 2020, 7:38 PM
Pancham Das
Pancham Das - avatar
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; }
10th Jul 2020, 8:03 PM
Jayakrishna 🇮🇳