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

1. Rewrite the following if else statements using a conditional operator . Assum

ID: 3545912 • Letter: 1

Question

1. Rewrite the following if else statements using a conditional operator . Assume all variables are declared properly.

If (x >=y)

Z=x-y;

Else

Z =y-x;


If (score>=60)

Str="pass";

Else  

Str="fail";


If (result>=0)

Cout<<the result is positive/n";

Cout << the result is negative/n"


2. Write a value returning function called smallest that determines the smallest number between two numbers. Both numbers are type integer

3. Write a void function called read that reads in the value of two numbers. Both numbers are type integer .

4. Write a void

Explanation / Answer

Question - 1

-------------


1) x>=y?Z=x-y:Z=y-x


2) scores>=60?Str="pass":Str=y-x


3) results>=0?cout<<"the result is positive":cout<<"the result is negative "


Question - 2

-------------


int retunSmallest(int n1, int n2)

{

int num1,num2;

int smallValue=0;

num1>num2?smallValue=num2:smallValue=num1

return smallValue;

}



Question - 3

------------


void readThat()

{

int num1,num2;

cout<<"Enter the first value to compare: ";

cin>>num1;

cout<<"Enter the second value to compare: ";

cin>>num2;

}