Stimulate calculators to perform addition,subtraction,multiplication and division on two numbers using if/else statement?



Stimulate calculators to perform addition,subtraction,multiplication and division on two numbers usi..

Answer / guest

void main()
{
int n,a,b;
sanf("%d%d",&a,&b);
printf("select one of these");
printf("1.addition
2.subtraction
3.multiplication
4.division");
scanf("%d",&n);
if(n==1)
{
printf("%d",a+b);
}
else if(n==2)
{
printf("%d",a-b);
}
else if(n==3)
{
printf("%d",a*b);
}
else if(n==4)
{
printf("%d",a/b);
}
else
{
printf("nothing to print");
}
}

Is This Answer Correct ?    13 Yes 4 No

Post New Answer

More C Interview Questions

Hi Every one......... Please Any body give me the answer for my question. Is it possible to print the word "PRINT F", without using printf() statement in C-Language.

4 Answers  


Magic square

0 Answers  


Explain the use of 'auto' keyword

0 Answers  


why wipro wase

0 Answers   Wipro,


What is property type c?

0 Answers  






What are the valid places to have keyword “break”?

0 Answers  


How can I recover the file name given an open stream?

0 Answers  


Can we initialize extern variable in c?

0 Answers  


What is a program flowchart and explain how does it help in writing a program?

0 Answers  


wtite a program that will multiply two integers in recursion function

4 Answers   TCS,


Why doesn't C have nested functions?

2 Answers  


Can anyone help me with this please? Need to print the below values.. Thanks 1 1 2 1 2 3 1 2 3 4

3 Answers  


Categories