0% found this document useful (0 votes)
53 views6 pages

Comment / // Comment / // Comment Both // Comment or / Comment

The document contains 35 multiple choice questions about C++ programming concepts like data types, operators, comments, header files, output statements, variables and more. The answer key is not provided.

Uploaded by

Ragh Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views6 pages

Comment / // Comment / // Comment Both // Comment or / Comment

The document contains 35 multiple choice questions about C++ programming concepts like data types, operators, comments, header files, output statements, variables and more. The answer key is not provided.

Uploaded by

Ragh Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1) Which of the following is used for comments in C++?

a) /* comment */
b) // comment */
c) // comment
d) both // comment or /* comment */

2) A C++ code line ends with ___


a) A Semicolon (;)
b) A Fullstop(.)
c) A Comma (,)
d) A Slash (/)

3) Preprocessor directives begin with a


a) !
b) >
c) #
d) ;

Which of the following is the correct syntax to add the header file in the C++
4)
program?
a) #include<userdefined>
b) #include- [userdefined.h]
c) <include> "userdefined.h"
d) Both A and B

5)
Which of the following is the correct syntax to print the message in C++ language?
a) cout <<"Hello world!";
b) Cout << Hello world! ;
c) Out <<"Hello world!;
d) None of the above

Which of the following comment syntax is correct to create a single-line comment


6)
in the C++ program?
a) //Comment
b) /Comment/
c) Comment//
d) None of the above
For inserting a new line in C++ program, which one of the following statements can
7)
be used?
a) \a
b) \r
c) \n
d) None of the above

8) a group of statements, such as the contents of a function, is enclosed in


a) Parentheses ()
b) Braces {}
c) Brackets <>
d) All of the previous

9) A____is a diagram that shows the logical flow of a program.


a) moody chart
b) free body
c) Pseudocode
d) flowchart

10) ____is a cross between human language and a programming language


a) moody chart
b) free body
c) Pseudocode
d) flowchart

11) Computers can do many different jobs because they can be _______
a) smart
b) programmable
c) thinking
d) non of the above

12) A(n) __________ is an example of a secondary storage device.


a) mouse
b) motherboard
c) flash memory drive
d) Ram

13) __________ is the only language computers really process.


a) machine language
b) high level language
c) English
d) non of the above

14) Every C++ program must have a Function main


a) TRUE
b) FALSE

15) "Hello World" is an example of _____


a) variables
b) functions
c) literals or constants
d) loops

16) Which of the following are not valid assignment statements?


a) letter = 'W';
b) total = 9;
c) profit = 129;
d) 72 = amount;

17) Which of the following are not valid cout statements?


a) cout << "Hello World";
b) cout << "Have a nice day"\n;
c) cout << value;
d) cout << "Programming is great fun";

A(n) ___________ is like a variable, but its value is read-only and cannot be
18)
changed during the program’s execution.
a) secure variable
b) uninitialized variable
c) named constant
d) locked variable

19) When do preprocessor directives execute?


a) Before the compiler compiles your program
b) After the compiler compiles your program
c) At the same time as the compiler compiles your program
d) None of the above

20) A variable must be defined before it can be used.


a) TRUE
b) FALSE

A left brace in a C++ program should always be followed by a right brace later in
21)
the program.
a) TRUE
b) FALSE
c)
d)

22) the negation sign is ______


a) unary
b) binary
c) ternary
d) all of the above

23) in the following operation (6+6/6*4)


a) the (+) has higher precedence than the (*)
b) the(/) has lower presedence than (+)
c) the (/)has higher presedence than(+)
d) non of the above

24) in the following operation (6+6/6*4) =?


a) 1
b) 0.5
c) 10
d) 6.25

25) 6-3*2+7-1 =?
a) 0
b) 2
c) 12
d) 6

26) 4 + 17 % 2 - 1 =?
a) 2
b) 4
c) 6
d) 8

27) (4 + 17) % 2 - 1 =?
a) 0
b) 1
c) 10
d) 20

28) int x =6.4; the value stored in x will be (?)


a) 6.4
b) 7
c) 6
d) 0.4

29) double x= 3/2 ; the value stored in x will be(?)


a) 1.5
b) 2
c) 1
d) non of the above

30) double x= 3.0/2 ; the value stored in x will be(?)


a) 1.5
b) 2
c) 1
d) non of the above

31) int x=5; x=x+10; the value last stored in x will be (?)
a) 5
b) 10
c) 15
d) 20

32) int x=5; x=x/2; the value last stored in x will be (?)
a) 5
b) 2
c) 2.5
d) 1

33) double x=5; x=x/2; the value last stored in x will be (?)
a) 5
b) 2
c) 2.5
d) 1
34) int x=5; x+=5; the value last stored in x will be (?)
a) 5
b) 10
c) 15
d) 0

35) int x=5; x-=5; the value last stored in x will be (?)
a) 5
b) 10
c) 15
d) 0

You might also like