whats the output of the following program?
#include <iostream>
using namespace std;
int main ()
{
int fistNum = 28;
int secondNum = 25;
cout << firstNum << " " << secondNum << end1;
cout << (firstNum = 38-7) << end1;
cout << (firstNum <= 75) << end1;
cout << (firstNum > secondNum + 10) << end1;
cout << (firstNum >= 3 * secondNum - 100) << end1;
cout << (secondNum - 1 == 2 * firstNum) << end1;
cout << firstNum << " " << secondNum << end1;
return 0;
}
28 25
31
1
0
1
0
31 25
Explanation:
int firstNum = 28;
int secondNum = 25;
cout << firstNum << " " << secondNum << endl; // 28 and 35 will be printed
cout << (firstNum = 38-7) << endl; // firstNum will become 31 and then it will be printed
cout << (firstNum <= 75) << endl; // 31<=75 true so 1 will be printed
cout << (firstNum > secondNum + 10) << endl; // 31> 25+10 31 >35 false so 0 will be printed
cout << (firstNum >= 3 * secondNum - 100) << endl; // 31 >= 3*25-100 i.e., 31>=-25 true so 1 will be printed
cout << (secondNum - 1 == 2 * firstNum) << endl; // 25-1==2*31i.e., 24==62 false so 0 will be printed
cout << firstNum << " " << secondNum << endl; // 31 and 25 will be printed
Get Answers For Free
Most questions answered within 1 hours.