1 / 11

Chapter 1 Quiz Questions (CGS-3464)

Chapter 1 Quiz Questions (CGS-3464). Mahendra Kumar makumar@cise.ufl.edu. Question 1. Which of the following is a valid name for an identifier? interest rate 2fast cout _foobar_2. Question 2. What data types can be used to store numeric values with a decimal point, such as 3.14 ? char

Download Presentation

Chapter 1 Quiz Questions (CGS-3464)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 1 Quiz Questions (CGS-3464) Mahendra Kumar makumar@cise.ufl.edu

  2. Question 1 • Which of the following is a valid name for an identifier? • interest rate • 2fast • cout • _foobar_2

  3. Question 2 • What data types can be used to store numeric values with a decimal point, such as 3.14 ? • char • short, int • Long • float, double

  4. Question 3 • Which of the following statements will correctly output the quote: Dan Quayle once said, "Who's responsible for the riots? The rioters." • cout << "Dan Quayle once said, Who's responsible for the riots? The rioters."; • cout << "Dan Quayle once said, \"Who's responsible for the riots? The rioters. \" "; • cout << "Dan Quayle once said, "Who's responsible for the riots? The rioters. " "; • cout << "Dan Quayle once said, "Who\'s responsible for the riots? The rioters. " ";

  5. Question 4 • What value is stored in variable x? int x; x = 2 * 3 + 4 * 5 + 4 / 2; • 11 • 23 • 28 • 14

  6. Question 5 • What value is stored in x after the following two statements are executed: int x; x = 2 / 4 * 4 / 2; • 0.0625 • 1.0 • 1 • 0

  7. Question 6 • Runners often think of their speed in terms of how many minutes and seconds it takes to run a mile, but most treadmills express speed in miles per hour. Which expression correctly converts from 6.5 miles per hour to output the pace in minutes and seconds? • int secsPerMile = static_cast int paceMins, paceSecs; paceMins = secsPerMile / 60; paceSecs = paceMin % 60; 2. int secsPerMile = static_cast int paceMins, paceSecs; paceMins = secsPerMile / 60; paceSecs = secsPerMile / 60 / 60; 3. int secsPerMile = static_cast int paceMins, paceSecs; paceMins = secsPerMile / 60; paceSecs = secsPerMile % 60; 4. int secsPerMile = static_cast int paceMins, paceSecs; paceMins = secsPerMile / 60; paceSecs = secsPerMile % 60;

  8. Question 7 • What will the following code output? int x, y; x=3; y=(++x)*2; cout << x << " " << y << endl; • 4 8 • 4 6 • 3 6 • 3 8

  9. Question 8 • How can we input a value from the keyboard and store it in the variable named num? • cin >> num; • cout << num; • num = input(); • cin << num;

  10. Question 9 • Which of the following is an invalid comment? • /* Comment regarding the program */ 2. /************************** * Comment about the program **************************/ • /* Comment regarding the program 4. // Comment regarding the program

  11. Question 10 • For a newer C++ compiler, what must be added to the top of the program to allow access to cin and cout? • #include<iostream.h> • #include using namespace std; 3. #include<iostream> using namespace std; 4. using namespace std;

More Related