C++ Which of the following is a correct way to ensure that once we read a nonnegative value into x, the loop will stop? (1) int x; while(x > x; if(x =0”; } (2) int x; for(cin >> x ; x > x; cout =0”;...


C++


Which of the following is a correct way to ensure that once we read a nonnegative value into x, the loop will stop?


(1)


int x;
while(x <>
cin >> x;
if(x <>
cout < “x="" must="" be="">=0”;
}


(2)


int x;
for(cin >> x ; x < 0="">
cin >> x;
cout < “x="" must="" be="">=0”;


(3)


int x;
do{
cin >> x;
if(x <>
cout < “x="" must="" be="">=0”;
}


(4)


int x;
cin >> x;
while(x <>
cin >> x;
cout < “x="" must="" be="">=0”;
}



Choices:


a. 2 and 4


b. 3 and 4


c. 2 and 3


d. 1 and 3



Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here