how to make a simple calculator in c
#include<stdio.h>
int main()
{
int a, b, s, i;
printf("Enter the first number: \n");
scanf("%d", &a);
printf("Enter the seacond number: \n");
scanf("%d", &b);
printf("......Menu.....\n 1 for addiction \n 2 for substraction \n 3 for multipliction \n 4 for divition \n enter your choice:");
scanf("%d", &i);
if(i==1)
s = a+b;
else if (i==2)
s = a-b;
else if (i==3)
s = a*b;
else if (i==4)
s = a/b;
else ("You entered the wrong input");
printf("The result is %d", s);
return 0;
}
Comments
Post a Comment