Cprog
Cprog
Cprog
html
Question 1
In an assignment statement a=b; Which of the following statement is true? a. The variable a and the variable b are equal. b. The value of b is assigned to variable a but the later changes on variable b will not effect the value of variable c. The value of b is assigned to variable a and the later changes on variable b will effect the value of variable a d. The value of variable a is assigned to variable b and the value of variable b is assigned to variable a.
Question 2
All of the following are valid expressions in C++ a = 2 + (b = 5); a = b = c = 5; a = 11 % 3 a. True b. False
Question 3:
To increase the value of c by one which of the following statement is wrong? a. c++; b. c = c + 1; c. c + 1 => c; d. c += 1
Question 4:
When following piece of code is executed, what happens? b = 3; a = b++; a. a contains 3 and b contains 4 b. a contains 4 and b contains 4 c. a contains 4 and b contains 3 d. a contains 3 and b contains 3
Question 5:
The result of a Relational operation is always a. either True or False b. is less than or is more than c. is equal or less or more d. All of these
Question 6:
Which of the following is not a valid relational operator? a. == b. => c. >= d. >=
Question 7:
What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run? A. 10 B. 9 C. 0 D. 1
Question 8:
When does the code block following while(x<100) execute? A. When x is less than one hundred B. When x is greater than one hundred C. When x is equal to one hundred D. While it wishes
Question 9:
Which is not a loop structure? A. for B. do while C. while D. repeat until
Question 10:
How many times is a do while loop guaranteed to loop? A. 0 B. Infinitely C. 1 D. Variable
Answers
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. b. The value of b is assigned to variable a but the later changes on variable b will not effect the value of variable a a. True c. c + 1 => c; a. a contains 3 and b contains 4 a. either True or False b. => A. 10 A. When x is less than one hundred D. Repeat Until C. 1
Question 1
A variable is/are a. String that varies during program execution b. A portion of memory to store a determined value c. Those numbers that are frequently required in programs d. None of these
Question 2
Which of the following can not be used as identifiers? a. Letters b. Digits c. Underscores d. Spaces
Question 3
Which of the following identifiers is invalid? a. papername b. writername c. typename d. printname
Question 4
Which of the following can not be used as valid identifier? a. bitand b. bittand c. biand d. band
Question 5
The difference between x and x is a. The first one refers to a variable whose identifier is x and the second one refers to the character constant x b. The first one is a character constant x and second one is the string literal x c. Both are same d. None of above
Question 6
Which of the following is not a valid escape code? a. \t b. \v c. \f d. \w
Question 7
Which of the following statement is true? a. String Literals can extend to more than a single line of code by putting a backslash sign at the end of each unfinished line. b. You can also concatenate several string constants separating them by one or several blank spaces, tabulators, newline or any other valid blank character
c. If we want the string literal to explicitly made of wide characters, we can precede the constant with the L prefix d. All of above
Question 8
Regarding #difine which of the following statement is false? a. It is not C++ statement but the directive for the preprocessor b. This does not require a semicolon at the end of line c. It is a C++ statement that declares a constant in C++ d. None of the above
Question 9
Regarding following statement which of the statements is true? const int pathwidth=100; a. Declares a variable pathwidth with 100 as its initial value b. Declares a construction pathwidth with 100 as its initial value c. Declares a constant pathwidth whose value will be 100 d. Constructs an integer type variable with pathwidth as identifier and 100 as value
Question 10
In an assignment statement a. The lvalue must always be a variable b. The rvalue might be a constant, a variable, an expression or any combination of these c. The assignment always takes place from right to left and never the other way d. All of above
Answers
1. b. A portion of memory to store a determined value 2. d. Spaces 3. c. Typename 4. a. Bitand 5. a. The first one refers to a variable whose identifier is x and the second one refers to the character constant x 6. d. \w 7. d. All of above 8. c. It is a C++ statement that declares a constant in C++ 9. c. Declares a constant pathwidth whose value will be 100 10. d. All of above
Question 1
Identify the correct statement a. Programmer can use comments to include short explanations within the source code itself. b. All lines beginning with two slash signs are considered comments. c. Comments very important effect on the behaviour of the program d. both
Question 2
The directives for the preprocessors begin with a. Ampersand symbol (& b. Two Slashes (//) c. Number Sign (#) d. Less than symbol (<
Question 3
The file iostream includes a. The declarations of the basic standard input-output library. b. The streams of includes and outputs of program effect. c. Both of these d. None of these
Question 4
There is a unique function in C++ program by where all C++ programs start their execution a. Start() b. Begin() c. Main() d. Output()
Question 5
Every function in C++ are followed by a. Parameters b. Parenthesis c. Curly braces
d. None of these
Question 6
Which of the following is false? a. Cout represents the standard output stream in c++. b. Cout is declared in the iostream standard file c. Cout is declared within the std namespace d. None of above
Question 7
Every statement in C++ program should end with a. A full stop (.) b. A Comma (,) c. A Semicolon ( d. A colon (
Question 8
Which of the following statement is true about preprocessor directives? a. These are lines read and processed by the preprocessor b. They do not produce any code by themselves c. These must be written on their own line d. They end with a semicolon
Question 9
A block comment can be written by a. Starting every line with double slashes (//) b. Starting with /* and ending with */ c. Starting with //* and ending with *// d. Starting with <!- and ending with -!>
Question 10
When writing comments you can a. Use code and /* comment on the same line b. Use code and // comments on the same line c. Use code and //* comments on the same line d. Use code and <!- comments on the same line
Answers
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. b. All lines beginning with two slash signs are considered comments. c. Number Sign (#) a. The declarations of the basic standard input-output library. c. Main() b. Parenthesis d. None of above c. A semicolon d. They end with a semicolon b. Starting with /* and ending with */ b. Use code and // comments on the same line
Question 1:
A function can not be overloaded only by its return type. a. True b. False
Question 2:
A function can be overloaded with a different return type if it has all the parameters same. a. True b. False
Question 3:
Inline functions involves some additional overhead in running time. a. True b. False
Question 4:
A function that calls itself for its processing is known as a. Inline Function b. Nested Function
Question 5:
We declare a function with ______ if it does not have any return type a. long b. double c. void d. int
Question 6:
Arguments of a functions are separated with a. comma (,) b. semicolon ( c. colon ( d. None of these
Question 7:
Variables inside parenthesis of functions declarations have _____ level access. a. Local b. Global c. Module d. Universal
Question 8:
Observe following function declaration and choose the best answer: int divide ( int a, int b = 2 ) a. Variable b is of integer type and will always have value 2 b. Variable a and b are of int type and the initial value of both variables is 2 c. Variable b is international scope and will have value 2 d. Variable b will have value 2 if not specified when calling function
Question 9:
The keyword endl a. Ends the execution of program where it is written b. Ends the output in cout statement c. Ends the line in program. There can be no statements after endl d. Ends current line and starts a new line in cout statement.
Question 10:
Strings are character arrays. The last index of it contains the null-terminated character a. \n b. \t c. \0 d. \1
Answers:
1. a. True 2. b. False 3. a. True 4. d. Recursive Function 5. c. Void 6. a. Comma (,) 7. a. Local 8. d. Variable b will have value 2 if not specified when calling function 9. d. Ends current line and starts a new line in cout statement 10. c. \0