Sie sind auf Seite 1von 4

Quiz #6

If originally x=10 and y=5 what is the value of each of the expressions:
1. ++x+y
2.--x+y
3.--x+(++y)
4.--x+y

If originally x=10, y=5, and z=2, evaluate the following expressions to true to false:
5. (x+1)!= y-2
6. !(x + y>20)
7. (x+1==y) || y-1>5
8. z+1>=3 || x+1<z*10 && y+3>7
9. Which of the following are not unary expressions?
a. a+b b. ++a c. a+=1

10. Which of the following are binary expressions?


a. a+b b. ++a c. a+=1 d. a++

11. Which of the following is not a logical operator in C++ language?


a.& b.&& c.|| d.!

12. Which of the following is not a comparison operator in C++ language?


a.> b.<= c.= d.==

Evaluate the following expressions to true or false


13. 3!=4-1
14. 5>=(1+6)-4
15.5+1==6 || 8-1>4
16.5>=6 || 1<8 && 9>7

17. What type of error does the C++ program have?


#include <iostream>
using namespace std;
int main () { /* This is the main function
cout<<”C++ Programming questions and answers”;
return 0;
}
a. Syntax error
b. Semantic Error

18. Find any errors in the following C++ program:


#include <iostream>
using namespace std;
void main () { // This is the main function
integer a;
float b;
}
a. Syntax error
b. Semantic Error

19. Find any errors in the following C++ program:


#include <iostream>
using namespace std;
int main () { // This is another C++ program with some errors
a,b,s int;
d float;
cout<<"The end of the program";
return 0;
}

20. What is the output from the following C++ program?


#include<iostream>
using namespace std;
int main (){ // This is another C++ program with some errors
int a, b, sum, subtr;
a=100; b=20;
sum=a+b;
subtr=a-b;
cout<<left;
cout<<setw(5)<<"a+b"<<setw(5)<<"a-b";
cout<<setw(5)<<sum<<setw(5)<<subtr;
}

21. The statement i++; is equivalent to


a. i = i + i;
b. i = i + 1;
c. i = i – 1;
d. i –;

22. In a C++ language ‘3’ represents


a. A digit
b. An integer
c. A character
d. A word

23. Value of a in a = (b = 5, b + 5); is


a. Junk value
b. Syntax error
c. 5
d. 10

24. The output of


{
int a = 5;
int b = 10;
cout << (a>b?a:b);
}
a. 5
b. 10
c. Syntax error
d. None of above

25. If x = 13 and y = 5, then which of the following expressions produce a false result?

a. x+2 <= y*3


b. x+7 != y*4
c. x+7 == y*4
d. x+2 > y*2

26-28. The int is one of the basic data types that can be manipulated by using the unary ++ operator. */
int main()
{
int a, b, c; // int data type for simple math
a = 9;
c = a + 1 + 1 * 0;
b = ++c;

return 0; // return main int as Exit Status 0 (success)


}
What are the final values of the variables a, b, and c?

29. Which of the following is not an advantage of secondary memory?


a. It is cost-effective
b. It has large storage capacity
c. It has highest speed
d. It is easily portable

30. Expression C=i++ causes


a. Value of i assigned to C and then i incremented by 1
b. i to be incremented by 1 and then value of i assigned to C
c. Value of i assigned to C
d. i to be incremented by 1

Das könnte Ihnen auch gefallen