- (10%)
Determine whether the following code is correct or not. If it is
correct, predict its output. If it is incorrect, point out the
mistake(s).
// Comparing Values (P.122)
#include <iostream>
int main()
{
int a = 5;
int b = 2;
std::cout << (a = b) << std::endl;
std::cout << (a == b) << std::endl;
return 0;
}
- (10%)
Determine whether the following code is correct or not. If it is
correct, predict its output. If it is incorrect, point out the
mistake(s).
// Conditional Operator (P.133)
#include <iostream>
int main()
{
int i;
for (i=3; i<6; i++)
std::cout << ( i % 2 ?
"Even" : "Odd" ) << std::endl;
return 0;
}
- (10%)
Determine whether the following code is correct or not. If it is
correct, predict its output. If it is incorrect, point out the
mistake(s).
// for Loop (P.140)
#include <iostream>
int main()
{
int i;
for (i=1; i==6; i++)
{
std::cout << i
<< std::endl;
}
std::cout << "After the loop, i = " << i
<< std::endl;
return 0;
}
- (10%) What does "EAP" stand for?