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
Here is a good puzzle: how do you write a program which produces its own source code as output?
Write a program to generate random numbers in c?
What are the advantages and disadvantages of pointers?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
Are the variables argc and argv are always local to main?
define string ?
What is register variable in c language?
main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above
What is wrong with this program statement?
Explain is it valid to address one element beyond the end of an array?
How can I split up a string into whitespace-separated fields?
What does %2f mean in c?
How does struct work in c?
Why structure is used in c?
What is the ANSI C Standard?