exam1sol - 1.) int x = 2 * 3 + 4 * 5; What value will x...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1.) int x = 2 * 3 + 4 * 5; What value will x contain in the sample code above? A. 22 B. 26 C. 46 D. 50 E. 70 2.) Which of the following is not true? A. Function name must start with a capital letter B. Variable name cannot start with a number C. main() function can return nonzero value D. a=b=c is a legal expression in C++ E. n%2==1 is true if and only if n is odd 3.) int x = 3; if( x != 2 ) x = 0; if( x = 3 ) x+=2; else x++; What value will x contain when the sample code above is executed? A. 1 B. 2 C. 3 D. 4 E. 5 4.) a-=++b is equivalent to A. b=b-1;a=b; B. b=b+1;a=a-b; C. a=a-b;b=b+1; D. a=a+1;b=a-b;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
E. b=b+1;a=b-a; 5.) What will the following code print? #include<iostream> using namespace std; void swap(int c;c=a;a=b;b=c;} int main() {int x=1,y=2;swap(x,y);cout << x << ","<<y; return 0; } A. 1,1 B. 1,2 C. 2,1 D. 2,2 E. The code contains compilation error(s) 6.) Code: int x = 0; for (x=1; x<4; x++); cout<<x; What will be printed when the sample code above is executed? A. 0
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/05/2011 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.

Page1 / 5

exam1sol - 1.) int x = 2 * 3 + 4 * 5; What value will x...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online