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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

How will you print TATA alone from TATA POWER using string copy and concate commands in C?

916


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

1507


what are non standard function in c

1429


What does s c mean on snapchat?

579


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

805






Why is c known as a mother language?

740


what is use of malloc and calloc?

1377


What are the features of c language?

617


What are bitwise shift operators in c programming?

639


Explain how can you avoid including a header more than once?

593


how to create duplicate link list using C???

2068


program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

1618


‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .

2366


What is the difference between printf and scanf )?

585


How does placing some code lines between the comment symbol help in debugging the code?

538