Simple Calculator
Simple Calculator
Simple Calculator
#include<stdio.h>
void main()
{
int a,b,ad,sb,ml,dv,e;
printf("\tWelcome to our simple calculator\n");
printf("enter number 1\n");
scanf("%d",&a);
printf("enter number 2\n");
scanf("%d",&b);
printf("\t\tMathematical operation");
printf("\n..............................................");
printf("\n1- Addition");
printf("\n2- Subtraction");
printf("\n3- Multiplication");
printf("\n4- Division");
printf("\n..............................................");
printf("\n Enter number of your preference:");
ad=a+b;
sb=a-b;
ml=a*b;
dv=a/b;
scanf("%d",&e);
switch(e)
{
case 1: printf("\n Addition is %d\n",ad);
break;
case 2:
printf("\n Subtraction is %d\n",sb);
break;
case 3: printf("\n Multiplication is%d\n",ml);
break;
case 4: printf("\n Division is %d\n",dv);
break;
default: printf("\n Incorrect input\n");
break;
}
}
Program to find even and odd
#include<stdio.h>
int main()
{
int a;
printf ("enter the value of the number");
scanf("%d",&a);
if (a%2==0)
{
printf("even number");
}
else
{
printf("odd number");
}
return 0;}