C Program to Make a Simple Calculator using if else if statement in c programming-99webcode
#include<stdio.h>
int main()
{
int ch;
int a,b;
int c;
printf("welcome to sr calsi");
printf("\nenter first number");
scanf("%d",&a);
printf("\nenter second number");
scanf("%d",&b);
printf("\nenter your choice\n1 for +\n2 for -\n3 for * \n4 for / \n5 for %");
printf("\nenter key ");
scanf("%d",&ch);
if(ch==1)
{
c=a+b;
printf("%d" ,c);
}
else if(ch==2)
{
c=a-b;
printf("%d" ,c);
}
else if(ch==3)
{
c=a*b;
printf("%d" ,c);
}
else if(ch==4)
{
c=a/b;
printf("%d" ,c);
}
else if(ch==5)
{
c=a%b;
printf("result is:%d" ,c);
}
else
{
printf("oops you have entered wrong number");
}
}
output:
welcome to sr calsi
enter first number 10
enter second number 12
enter your choice
1 for +
2 for -
3 for *
4 for /
5 for
enter key 3
result is : 120