How To Make A Calculator In C

Well don’t depend on your teacher to complete your work, make the proud do more then what they tell you to do.

calculator

Its a mess when you try learning C and you know C++ at its best. Well I am also facing this problem for quite a long time now. C is making me mad, its interesting. Well the main difference between C and C++ is just flexibility. Its when you know that by just adding %d your job gets done without any problem. Well look at that side, I got a program ready for you and its a calculator. Check out the code below.

 

So the program goes like this : 

#Include<stdio.h>
#Include<conio.h>
voidmain()
{
clrscr();
int a, b, c, o;

printf(“Enter two numbers to be calculated : “);
scanf(“%d%d”,&a,&b);

//OPERATOR SELECTION
printf(“Add, Multiply, Devide or Substract ?”),
scanf(“%d”,&c);
//CHOICE SELECTION

if (c=Add)
{
o=a+b;
}
else if (c=Multiply)
{
o=a*b;
}
else if (c=Devide)
{
o=a/b;
}
else if (c=Substract)
{
o=a-b;
}
else
{
printf(“Invalid Operator Used”);
}
printf(“The Answer Is : %d”,o);
getch();
}

And that’s just it, everything works by itself. I’ll be doing a explanation Video soon. Thanks for reading, share a little bit 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *