Exercise – 6 Control Flow - III
Aim:Write
a C Program to make a simple Calculator to Add, Subtract, Multiply or Divide
Using switch case.
Program:-
#include<stdio.h>
void main()
{
int a,b,c,ch;
printf("enter a, b values");
scanf("%d%d",&a,&b);
printf(" 1.ADD 2.SUB 3.MUL 4.DIV ");
printf("\nenter your choice");
scanf("%d",&ch);
switch(ch)
{
case
1:c=a+b;
printf("\nsum
is %d",c);
break;
case
2:c=a-b;
printf("\nsub
is %d",c);
break;
case
3:c=a*b;
printf("\nmul
is %d",c);
break;
case 4:
c=a/b;
printf("\ndiv
is %d",c);
break;
default:printf("enter
correct choice");
break;
}
}
Cool you write, the information is very good and interesting, I'll give you a link to my site. 140 lbs to kg
ReplyDelete