A Quick Look at C++

A simple and basic C++ code example. Explore your logical understanding of programming wither you are a beginner or it is your first C++ encounter.

download Export
search_insights Statistics
stylus_note White Board
Quran
calculate Calculator
dictionary Dictionary
fullscreen Full Screen
QUESTION OF

volume_mute Read quiz aloud
Views #: 1352
Questions #: 18
Time: 15 minutes
Pass Score: 80.0%
Style
Mode

In general, this progrm

1 pts
volume_mute
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


Sample Run: (When you compile and execute this program, the following five lines are displayed on the screen)

1 pts
volume_mute
Program to compute and output the perimeter and area of a rectangle.
Length = 6
Width = 4
Perimeter = 20
Area = 24
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


The output of the program is generated by executing the following statements

1 pts
volume_mute
cout << "Program to compute and output the perimeter and " <<  "area of a rectangle." << endl;
cout << "Length = " << length << endl;
cout << "Width = " << width << endl;
cout << "Perimeter = " << perimeter << endl;
cout << "Area = " << area << endl;
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


Explain how this happens

1 pts
volume_mute
cout << "Program to compute and output the perimeter and " <<  "area of a rectangle."  << endl;

This is an example of a C++ (1) statement. It causes the computer to evaluate the (2) after the pair of symbols << and display the (3) on the screen

Please drag and drop the selected option in the right place or type it instead
output
result
expression
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


Arithmetic expression or a string?

1 pts
volume_mute
length + width

is an example of 

note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


"Program to compute and output the perimeter and " is an example of a string

1 pts
volume_mute
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


endl

1 pts
volume_mute
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


cout << "Length = " << length << endl;

1 pts
volume_mute
Missing

What does the second length evaluate to?

(write a whole number without decimal points)

note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


There is no way to output length value as 6.0?

1 pts
volume_mute
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


return 0;

1 pts
volume_mute

returns zero to the program itself which continues running

note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


Main function

1 pts
volume_mute

A C++ program can execute without a main function

note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


Anything comes after // is not executable

1 pts
volume_mute
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


#include <iostream>

1 pts
volume_mute
#include <iostream>

allows us to use the (predefined object) cout to generate output and the (manipulator) endl.

note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


using namespace std;

1 pts
volume_mute
using namespace std;

This statement is useless.  You can remove it and the program still compiles.

note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


int main()

1 pts
volume_mute
int main()

This is the (1) of the function main. The next line consists of a (2). This marks the beginning of the (body) of the function main. The (3) (at the last line of the program) matches this (4) and marks the end of the body of the function main.

Please drag and drop the selected option in the right place or type it instead
heading
right brace
left brace
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


Stream insertion operator

1 pts
volume_mute
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


Various parts of a C++ program

1 pts
volume_mute

Match certain program sections

  • (1) lines from 1 to 4
  • (2) lines from 11 to 14
  • (3) lines from 19 to 22
  • (4) lines from 23 to 26
Please drag and drop the selected option in the right place or type it instead
Assignment statements
Variable declarations
Comments
Output statements
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation


So length, width, area, and perimeter are all __________

1 pts
volume_mute
Missing
note_alt Add notes
flag Flag
volume_mute

Correct Answer

Explanation

Keywords
Year 10