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

Your program should present a menu with 4 options, 1) Print author info 2) perfo

ID: 3888251 • Letter: Y

Question

Your program should present a menu with 4 options,
1) Print author info
2) perform integer operation
3) perform floating point operation
0) Exit

Where selection 1 prints your information (name and student id)
selection two performs an integer math operation
selection 3 performs a floating point (non whole number) math operation.
Selection 0 will exit the program immediately.
Any other selection will print an error message stating that an invalid selection was made.

When one of the math operation selections are chosen, the user will enter a simple math formula (such as "1+1") you should then calculate the result of their entered formula and print both the operation and the result to the screen.
The result should be preceeded by the text "OUTPUT: "
The result should include two values to the right of the decimal.
for example if the user entered:
"4*6"

You would print:
OUTPUT: 4 * 6 = 24.00

You can expect the user to enter the formula in the format of:
op1<operand>op2 where there is no white space in the formula.

The operations you must support are:
+ addition
- subtraction
* multiplication
/ division
% modulus (integer operations only)

Make sure your results are mathematically correct (you will be graded on math as if this were a math class.

To get full credit you need to follow the output rules exactly.
the file check.sh can be used to check some basic operations for your program.
Run it from the command prompt using the following syntax
./check.sh _path_to_executable

Explanation / Answer

#include<stdio.h>

int main()

{

int select,aid,x,y,z,no=0; float a,b,c;

while(no<1)

{

printf(“Please enter selection”);

scanf(“%i”,&select);

if(select==1)

{

printf(“The author is Ryan”);

printf(“Enter the author id”);

scanf(“%i”,aid);

printf(“The author id is %i”,aid);

}

else if(select==2)

{

printf(“Enter your first no:”);

scanf(“%i”,&x);

printf(“Enter your second no:”);

scanf(“%i”,&y);

z=x+y;

printf(“%i+%i=%i”,&x,&y,&z);

z=x-y;

printf(“ %i-%i=%i”,&x,&y,&z);

z=x*y; printf(“ %i *%i=%i”,&x,&y,&z);

z= x / y;

printf(" %i / %i = %i", &x, &y, &z);

z = x%y;

printf("%i mod %i = %i ", &x, &y, &z);

}

else if(select==3)

{

printf(“Enter your first no”);

scanf(“%f”,&a);

printf(“Enter your second no:”);

scanf(“%f”,&b);

c=a+b;

printf(“ %f +%f =%f”,&a,&b,&z);

c=a-b;

printf(“ %f - %f =%f”,&a,&b,&c);

c=a*b;

printf(“ %f * %f=%f”,&a,&b,%c);

c=a/b;

printf(“ %f/%f=%f”, &a,&b,&c);

}

else

no++;

}

return 1;

}