Download presentation
Presentation is loading. Please wait.
Published byMaude Burns Modified over 9 years ago
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? 1.interest rate 2.2fast 3.cout 4._foobar_2
3
Question 2 What data types can be used to store numeric values with a decimal point, such as 3.14 ? 1.char 2.short, int 3.Long 4.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." 1.cout << "Dan Quayle once said, Who's responsible for the riots? The rioters."; 2.cout << "Dan Quayle once said, \"Who's responsible for the riots? The rioters. \" "; 3.cout << "Dan Quayle once said, "Who's responsible for the riots? The rioters. " "; 4.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; 1.11 2.23 3.28 4.14
6
Question 5 What value is stored in x after the following two statements are executed: int x; x = 2 / 4 * 4 / 2; 1.0.0625 2.1.0 3.1 4.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? 1.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; 1.4 8 2.4 6 3.3 6 4.3 8
9
Question 8 How can we input a value from the keyboard and store it in the variable named num? 1.cin >> num; 2.cout << num; 3.num = input(); 4.cin << num;
10
Question 9 Which of the following is an invalid comment? 1./* Comment regarding the program */ 2./************************** * Comment about the program **************************/ 3./* 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? 1.#include 2.#include using namespace std; 3.#include using namespace std; 4.using namespace std;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.