Answer following questions. Assume the all the code snippets are syntactically c
ID: 647763 • Letter: A
Question
Answer following questions. Assume the all the code snippets are syntactically correct and embedded in a correct program. Write your answers in the text file, apple.txt.
b) Assuming that a user enters 45, 78, and then 12, what is the output of the following code
snippet?
int num1 = 0;
int num2 = 0;
int num3 = 0;
cout<<"Enter a number: ";
cin>>num1;
cout<<"Enter a number: ";
cin>>num2;
cout<<"Enter a number: ";
cin>>num3;
if (!(num1 > num2 && num1 > num3))
{
cout<<num1;
}
else if (!(num2 > num1 && num2 > num3))
{
cout<<num2;
}
else if (!(num3 > num1 && num3 > num2))
{
cout<<num3;
}
Explanation / Answer
b) Assuming that a user enters 45, 78, and then 12, what is the output of the following code
snippet?
int num1 = 0;
int num2 = 0;
int num3 = 0;
cout<<"Enter a number: ";
cin>>num1;
cout<<"Enter a number: ";
cin>>num2;
cout<<"Enter a number: ";
cin>>num3;
if (!(num1 > num2 && num1 > num3))
{
cout<<num1;
}
else if (!(num2 > num1 && num2 > num3))
{
cout<<num2;
}
else if (!(num3 > num1 && num3 > num2))
{
cout<<num3;
}
output: 45 //since 78 < 45 is false so !false is true.