SAMPLE EXAM QUESTIONS-good

SAMPLE EXAM QUESTIONS-good - SAMPLE EXAM QUESTIONS CHAPTER...

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

View Full Document Right Arrow Icon
SAMPLE EXAM QUESTIONS CHAPTER 2 (INTRODUCTION TO C++) 2-1. How many of the following variable names are valid in C++? For 7_years_ago _we beat_FSU A. 1 B. 2 C. 3 D. 4 E. 5 2-2. What is the output of the following C++ program ? #include<iostream.h> int main(void) { int i1, i2, i3, i4; float x1, x2, x3, x4; i1 = 3. / 5; i2 = 3 / 5.0; i3 = 3.0 / 5.0; i4 = 3 / 5; x1 = 3. / 5; x2 = 3 / 5.0; x3 = 3.0 / 5.0; x4 = 3 / 5; cout << i1 << i2 << i3 << i4 << x1 << x2 << x3 << x4; return 0; } A. 0.60.60.600.60.60.60 B. 0.60.60.600.60.60.60.6 C. 0000.60.60.60 D. 00000.60.60.60.6 E. 00000.60.60.60 2-3. How many of the following variable names are valid in C++? 1. _x 2. 4xy 3. if
Background image of page 1

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

View Full DocumentRight Arrow Icon
4. x+y 5. _9y A. 1 and 5 B. 2 and 4 C. 1, 3 and 5 D. 2, 3 and 4 E. 3, 4 and 5 2-4. What is the output for the C++ program? #include <iostream.h> int main (void) { int x; float y; x=2.8; y=4.1; cout<<x+y; return 0; } A. 6.9 B. 6.1 C. 6.8 D. 7.1 E. 7.0 2-5. Which are valid variable names in C++? 1. quantity 2. #Account 3. Quantity 4. _taxchange2 A. 1 and 2 B. 1, 2 and 3 C. 1, 3 and 4 D. 2, 3 and 4 E. 3 and 4 2-6. What is the value of n? int j,k,l,m,n; cin >> j; // user enters 4.5 k=3+j; l=j+k; m=l*k; n=m+3;
Background image of page 2
cout<<n; A. 47 B. 80 C. 77 D. 52 E. 59 2-7. Which of the following statements is incorrect? A. x=5; B. y=sqrt(pow(a,2)+b*b); C. x+y=z; D. k=3/7; E. x=x+y; 2-8. Which variable name is valid? A. Solve B. solve C. sOLVE D. SOLVE E. All of the above 2-9. What is the output? #include <iostream.h> int main (void) { int a,b,c; float x,y; a=3/5; b=1.2; c=a+b; y=x=2*c; cout<<x+y; return 0; } A. 0 B. 2 C. 4 D. 4.8 E. 7.2 2-10. Which of the following lines uses incorrect syntax? 1. cout<<x<<endl 2. cin>>y;
Background image of page 3

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

View Full DocumentRight Arrow Icon
3. cout>>_rate; 4. cin>>endl; A. 1,3 B. 1,2,3,4 C. 1,2 D. 1,3,4 E. 3,4 2-11. The next two questions refer to the following C++ program. #include <iostream.h> int main (void) { int miles; int feetPerMile; float feetdistance; miles=1.2; feetPerMile=5280; feetdistance=miles*feetPerMile; cout<<feetdistance; return 0; } What is the output? A. 5000 B. 5280 C. 6000 D. 6240 E. 6336 2-12. What will be the output in the previous question if all the variables are float? A. 5000 B. 5280 C. 6000 D. 6240 E. 6336 2.13. Below is the output of a segment of a C++ program. 7 feet and 8.5 inches
Background image of page 4
Which of the following will NOT produce the output? A. cout<<7<<” feet and “<<8+0.5<<” inches”<<endl; B. cout<<7.0<<” feet “<<”and “<<17/2.<<” inches\n”; C. cout<<’7’<<” feet and “<<8.5<<” inches”<<endl; D. cout<<”7”<<” feet and “<<17./2<<” inches”<<endl; E. cout<<7<<” feet and “<<17/2<<” inches”<<endl;
Background image of page 5

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

View Full DocumentRight Arrow Icon
SAMPLE EXAM QUESTIONS CHAPTER 3 (C++ BASICS) 3-1. Below is the output of a segment of a C++ program. 2 for 1
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 69

SAMPLE EXAM QUESTIONS-good - SAMPLE EXAM QUESTIONS CHAPTER...

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

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