Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a calculator with following details in C: For each of parts a to d , You

ID: 3601720 • Letter: D

Question

Design a calculator with following details in C:

For each of parts a to d , You SHOULD write a function for each operation and then call each function in the main() to do that specific operation.

Get two numbers a and b from user and ask user which operation he wants to do:

Calculate a+b

Calculate a*b

Calculate a-b

Calculate a/b

Write a code to print stars. You should get a name of month January to December from user and then print one star for Jan, print two stars for Feb and so on. You should print stars in a function starsPrint and call this function in your main(). Notice: you should just use 1 function not more.

Example:

Please insert name of a month:

User input: April

Output: ****

Explanation / Answer

#include<stdio.h>
int add(int a, int b)
{
return a+b;
}
int subtract(int a, int b)
{
return a-b;
}
int multiply(int a, int b)
{
return a*b;
}
int divide(int a, int b)
{
return a/b;
}
main()
{
int x, y, choice;
  
printf("Enter a: ");
scanf("%d",&x);
  
printf("Enter b: ");
scanf("%d",&y);
  
printf("1 for Addition 2 for Subtraction 3 for Multiplication 4 for Division Enter choice:");
scanf("%d",&choice);
  
if(choice==1)
printf("a+b = %d",add(x,y));
else if(choice==2)
printf("a-b = %d",subtract(x,y));
else if(choice==3)
printf("a*b = %d",multiply(x,y));
else if(choice==4)
printf("a/b = %d",divide(x,y));
}

/*
SAMPLE OUTPUT

Enter a: 8
Enter b: 2
1 for Addition
2 for Subtraction
3 for Multiplication
4 for Division

Enter choice: 3
a*b = 16


Enter a: 2
Enter b: 3
1 for Addition
2 for Subtraction
3 for Multiplication
4 for Division

Enter choice: 1
a+b = 5


Enter a: 5
Enter b: 1
1 for Addition
2 for Subtraction
3 for Multiplication
4 for Division

Enter choice: 2
a-b = 4


Enter a: 16
Enter b: 4
1 for Addition
2 for Subtraction
3 for Multiplication
4 for Division

Enter choice: 4
a/b = 4
*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote