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

the syntax of the language of the input for this calculator is: option left1 lef

ID: 3652721 • Letter: T

Question

the syntax of the language of the input for this calculator is:
option left1 left2 right1 right2 (these are all integers)

option int can be either a 1, 2, or 3, implying addition, subtraction, or multiplication, respectively. if anything else, terminate program.
The left and right operands are left1 * x + left2 and right1 * x + right2, respectively.

some sample input: 2 4 7 5 15 would mean (4x + 7) ? (5x + 15)

result of the operation on two linear polynomials can be a polynomial of degree 2
(case of multiplication), 1, or 0. so program will consider the result as a
polynomial of degree 2, and print the coe?cients from the term of the highest degree
to the term of lowest degree. More precisely, the output is always of the following form:

result1 result2 result3

above output means that the result is result1

Explanation / Answer

Slightly Changed: Try This & Please rate



#include
int main()
{
int Opt,L1,L2,R1,R2,XSQ,X,C;
printf(" Input the Operation[ either 1,2,3] & 4 integer values:");
scanf("%d,%d,%d,%d,%d",&Opt,&L1,&L2,&R1,&R2);
if(Opt==1 || Opt==2 || Opt==3)
{
switch(Opt)
{
case '1':
XSQ=L1*R1;
X= ((L1*R2)+(L2*R1));
C=L2*R2;
if( (XSQ>X && XSQ>C) || XSQ==X || XSQ==C)
{
if(X>C || X==C )
printf(" %d %d %d ",XSQ,X,C);
else
printf(" %d %d %d ",XSQ,C,X);
}
if( XSQC || X==C)
{
if(XSQ>C || XSQ==C)
printf(" %d %d %d ",X,XSQ,C);
else
printf(" %d %d %d ",X,C,XSQ);
}
if( XSQ {
if(XSQ>X)
printf(" %d %d %d ",C,XSQ,X);
else
printf(" %d %d %d ",C,X,XSQ);
}
break;
case '2':
printf("%d %d",(L1+R1),(L2+R2));
break;
case '3':
printf("%d %d",(L1-R1),(L2-R2));
break;
default:
break;
}
}
return 0;
}