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

Must Be Written In Basic C Please Do Not Use What Is On the Internet, I have Alr

ID: 2268527 • Letter: M

Question

Must Be Written In Basic C

Please Do Not Use What Is On the Internet, I have Already Found these and there are differences.

Create a simple scientific calculator program as follows:

Display a menu of options according to table.

Ask the user to enter a menu option (upper and lower case will work).

If menu option is not valid, display msg “invalid option” and repeat parts 1 and 2. (use do-while)

For “add” option ask the user to enter two numbers, store as double and display sum.

For subtract option ask the user to enter two numbers, store as double and display difference.

For multiply option, same as above.

For divide option, same as above(test the denominator, if zero, display an appropriate msg).

For remainder option, ask the user to enter two integers and displays remainder.

For squared, ask the user to input a number and output the square of the number.

For square root, check if the number is negative and output appropriate msg.

For factorial, ask for a number, if negative number is entered keep asking the user till zero or positive is entered, and output factorial ( 5! = 5*4*3*2*1). (use for loop)

For is even_odd, display msg indicating if number is even or odd.

For greater integer, round the number to an integer greater than number.

For less integer, round the number to an integer less than number.

Menu option

Operation

Variables

Sample input

Sample output

A

Add

Double , double

5.6 , 3

8.60

S

subtract

Double , double

5.6 , 3

2.60

M

multiply

Double , double

10    ,    4

40.00

D

divide

Double , double

10    ,    4

2.50

R

remainder

Integer , integer

8    ,     3

2

V

squared

double

2

4.00

T

Square root

double

9.0

3.00

F

factorial

integer

5

120

E

Is even_odd

integer

8

Is even

G

Greater integer

double

3.2

4

L

Less integer

double

3.2

3

X

Exit program

Menu option

Operation

Variables

Sample input

Sample output

A

Add

Double , double

5.6 , 3

8.60

S

subtract

Double , double

5.6 , 3

2.60

M

multiply

Double , double

10    ,    4

40.00

D

divide

Double , double

10    ,    4

2.50

R

remainder

Integer , integer

8    ,     3

2

V

squared

double

2

4.00

T

Square root

double

9.0

3.00

F

factorial

integer

5

120

E

Is even_odd

integer

8

Is even

G

Greater integer

double

3.2

4

L

Less integer

double

3.2

3

X

Exit program

Explanation / Answer

#include<stdio.h>
#include<math.h>
main()
{
   printf("Menu option operation A Add S Subtract M Multipli D Divide R Remainder V Squared T Squar root F Factorial E Is even G Greater Integer L Less integer E Exit Program");
   char ch;
   double a,b;
   int c,d,f,i,e;
   printf(" Enter the character to select menu option ");
   scanf("%c",&ch);
   if(ch>=97&&ch<=123)
   ch=ch-32;
  
       switch(ch)
   {
       case 'A':
           printf("Enter two numbers to add ");
           scanf("%d%d",&a,&b);
           printf("The addition of two number is %d",a+b);
           break;
       case 'S':
          
           printf("Enter two numbers to subtract ");
           scanf("%d%d",&a,&b);
           printf("The subtraction of two number is %d",a-b);
           break;
       case 'M':
          
           printf("Enter two numbers to multiply ");
           scanf("%d%d",&a,&b);
           printf("The multiplication of two number is %d",a*b);
           break;
       case 'D':
          
           printf("Enter two numbers to devide ");
           scanf("%d%d",&a,&b);
           printf("The dividion of two number is %d",a/b);
           break;
       case 'R':
           printf("Enter two numbers to find remainder ");
           scanf("%d%d",&c,&d);
           printf("The remainder of two number is %d",c%d);
           break;
       case 'V':
          
           printf("Enter a number to find squar of it ");
           scanf("%d",&a);
           printf("The addition of two number is %d",a*a);
           break;
       case 'T':
          
           printf("Enter a number to find squar root ");
           scanf("%d",&a);
           b=sqrt(a);
           printf("The squart root of number is %d",b);
           break;
       case 'F':
           printf("Enter a number to find factorial ");
           scanf("%d",&f);
           int fact=1;
           for(i=1;i<=f;i++)
           fact=fact*i;
           printf("The factorial of given number is %d",fact);
           break;
       case 'E':
           printf("Enter a number to check ever or not ");
           scanf("%d%d",&e);
           if(e%2==0)
           printf("The given number %d is even",e);
           break;
       case 'G':
           printf("Enter two numbers to give greater number ");
           scanf("%d%d",&a,&b);
           int great = a>b?a:b;
           printf("The greater number is %d",great);
           break;
       case 'L':
           printf("Enter two numbers to give less number ");
           scanf("%d%d",&a,&b);
           int less = a<b?a:b;
           printf("The lesser number is %d",less);
           break;
       case 'X':
           break;
       default:
           printf("Invalid input ");
           main();
   }
  

}