1. Review the following code and follow the instructions that follow. int main()
ID: 3552091 • Letter: 1
Question
1. Review the following code and follow the instructions that follow.
int main() {
int x = 4;
if (CODE SEGMENT)
cout << "YES " << endl;
return 0; }
Note that the code featured the phrase CODE SEGMENT where a Boolean expression would normally be. Which five of the following expressions can we use as replacements for CODE SEGMENT so that the output will be YES? (Feel free to copy and test each expression with the code in Visual C++. Note that more than five of the following expressions might work.)
x==2 x%4=0 x=2 x%4==0 x<4 6<4 x<=4 x=0
x>4 x==0 x%6=2 x=-2 x%6==2 x==-2 x%8==2 6%x==2
2. The following code asks the user to submit an integer value as input. Name at least three different integers that when provided as input would result in the output of YES. Feel free to copy and test the code in Visual C++.
int main() {
return 0;
Explanation / Answer
Ans 1 - x%4=0, x=2, x<=4, x=0, 6%x==2
Ans 2 - 8,16,24
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.