C Program for calculator using Switch - With Output

#include<conio.h>
#include<stdio.h>

void main()
{
int a,b,ch;
printf(“Enter any two numbers \t”);
scanf(“%d%d”,&a,&b);
printf(“1 – Addition\n2-Subtraction\n3-Multiplication\n4-Division\n Your Choice : ”);

scanf(“%d”,&ch);

switch(ch)
{
case 1: printf(“Result is : %d”,(a+b));
break;
case 2: printf(“Result is : %d”,(a-b));
break;
case 3: printf(“Result is : %d”,(a*b));
break;
case 4: printf(“Result is : %d”,(a/b));
break;
default:printf(“Invalid Choice”);

}

getch();
}

OUTPUT :

Enter any two number 6 2
1-Addition
2-Subtraction
3-Multiplication
4-Division
Your Choice : 2
Result is : 4
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment