Professional Documents
Culture Documents
Multiple Choice
Multiple Choice
Multiple Choice
For inserting a new line in C++ program, which one of the following statements
can be used?
a) \n
b) \r
c) \t
a) / comment;
b) // comment */
c) // comment
#include<iostream>
using namespace std;
int main()
{
int x = 5;
if (x <1)
cout<<"Hello";
}
a) Nothing
b) Run time error
c) Hello
a) Arithmetic
b) Relational
c) Logical
d) Both B and C
7. If we stored five elements or data items in an array, what will be the index
address or the index number of the array's last data item?
a) 3
b) 5
c) 4
9. What is the correct way to use cin for inputting an integer variable num in C++?
a) cin>>num;
b) num<<cin;
c) cin<<num;
d) num>>cin
10. What is the primary purpose of the cin object in C++?
a) decrementing
b) incrementing
c) counting
d) recursive
12. Which of the following is the proper syntax of a for loop in C++?
13. Which of the following is the default return value of functions in C++?
a) int
b) char
c) float
d) void
#include<iostream>
using namespace std;
int fun(int x = 0, int y = 0, int z){
return (x + y + z);
}
int main()
{
cout << fun(10);
return 0;
}
a) 10
b) 0
c) Error
d) Segmentation fault
a) To define a function
b) To declare a function before its usage
c) To initialize function variables
d) To terminate a function