Short Answer Type Question In C/C++

1. What symbol indicates that the following line is a comment?Answer: //   (or /*)
2.  What are the two kinds of statements inside a function?Answer:  Declaration statements and executable statements.
3.  What does the following statement do?cout << “This is good.”;Answer:  It displays the words "This is good" on the screen.
4.  What C++ word is used to read information in from the keyboard?Answer:  cin

(adsbygoogle = window.adsbygoogle || []).push({});

5.  What is the name for a word that has a specific meaning in C++?Answer:  Reserved word (or keyword)
6.   What is an identifier?Answer:  A name for the data elements used in a program.
7.  What would be the best choice for the data type for a person’s middle initial?Answer:  char
8.  What would be the best choice for the data type for the distance between two houses?Answer:  float (or double or long double)
9.  Write the following number in normal decimal notation: 734E-4Answer:  0.0734
10.  What is the escape sequence for a linefeed?Answer:  ‘\n’
11.  What is the following kind of statement called?int counter;Answer:  A variable declaration.
12.  If the variables name and color contain these values: name  color  “Elmo” “red”write a statement using these variables that will output: Elmo, the puppet, is red!Answer:  cout << name << “, the puppet, is “ << color << “!”;
13.  What is a prompt?Answer:  An output statement that informs the user what to enter.
14.  What is the output of the following code segment if the data entered are 3, 2 and 4?int x, y, z;cout << “Enter three numbers: “;cin >> x >> y >> z;y = x + z;x = z + 1;cout << x << “ “ << y<< “ “ << z;Answer:  5 7 4
15.  Why do programmers use comments?Answer:  To help others read and understand the program.
16.  What is the result of the following arithmetic expression?5 + 7/3Answer:  7

(adsbygoogle = window.adsbygoogle || []).push({});

17.  What is the result of the following arithmetic expression?7 – 2 * (4 + 1)Answer:  -3
18.  Write the following statement in C++: a = 2bc3Answer:  a = 2 * b * c * c * c
19.  If data is being read from a file for a program in batch mode, a prompt is replaced with what?Answer:  An echo.