Which of the following correctly declares an array?
a) int array[10];
b) int array;
c) array{10};
d) array array[10];
What is the index number of the last element of an array with 9 elements?
a) 9
b) 8
c) 0
d) Programmer-defined
What is a array?
a) An array is a series of elements of the same type in contiguous memory locations
b) An array is a series of element
c) An array is a series of elements of the same type placed in non-contiguous memory
locations
d) None of the mentioned
Which of the following accesses the seventh element stored in array?
a) array[6];
b) array[7];
c) array(7);
d) array;
What will be the output of this program?
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
#include <stdio.h>
using namespace std;
int array1[] = {1200, 200, 2300, 1230, 1543};
int array2[] = {12, 14, 16, 18, 20};
int temp, result = 0;
int main()
{
for (temp = 0; temp < 5; temp++) {
result += array1[temp];
}
for (temp = 0; temp < 4; temp++) {
result += array2[temp];
}
14.
15.
16.
cout << result;
return 0;
}
a) 6553
b) 6533
c) 6522
d) 12200
What will be the output of the this program?
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
#include <stdio.h>
using namespace std;
int main ()
{
int array[] = {0, 2, 4, 6, 7, 5, 3};
int n, result = 0;
for (n = 0; n < 8; n++) {
result += array[n];
}
cout << result;
return 0;
}
a)25
b)26
c)27
d) None of the mentioned
What is the output of this program?
1.
2.
3.
4.
5.
6.
7.
8.
#include <iostream>
using namespace std;
int main()
{
int const p = 5;
cout << ++p;
return 0;
}
a) 5
b) 6
c) Error
d) None of the mentioned
Where does the execution of the program starts?
a) user-defined function
b) main function
c) void function
d) none of the mentioned
What are mandatory parts in function declaration?
a) return type,function name
b) return type,function name,parameters
c) both a and b
d) none of the mentioned
which of the following is used to terminate the function declaration?
a) :
b) )
c) ;
d) none of the mentioned
What is the output of this program?
#include <iostream>
using namespace std;
void mani()
void mani()
{
cout<<"hai";
}
int main()
{
mani();
return 0;
}
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
a)hai
b)haihai
c)compiletimeerror
d) none of the mentioned
7. What is the output of this program?
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
#include <iostream>
using namespace std;
void fun(int x, int y)
{
x = 20;
y = 10;
}
int main()
{
int x = 10;
fun(x, x);
cout << x;
return 0;
}
a)10
b)20
c)compile
d) none of the mentioned
time
What is the scope of the variable declared in the user definied function?
a) whole program
b) only inside the {} block
c) both a and b
d) none of the mentioned
error