C for calculating usinf if else if ladder - 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);

if(ch==1)
printf(“Result is : %d”,(a+b));

else if(ch==1)
 printf(“Result is : %d”,(a-b));

else if(ch==1)
 printf(“Result is : %d”,(a*b));

else if(ch==1)
 printf(“Result is : %d”,(a/b));

else
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