You are on page 1of 5

1.

main()
{
int c= - -2;
cout<<c;
}

OUTPUT :[ ] /ERROR

2.
main()
{
int a= - 100;
a=!a>14;
cout<<a;
}

OUTPUT:[ ]/ERROR


3.
#define square(x) x*x
main()
{
int i;
i = 125/square(5);
cout<<i;
}

OUTPUT: [ ] /ERROR

4.
main()
{
char *farther;
int *farthest;
cout<<sizeof(farther);
cout<<sizeof(farthest);
}
OUTPUT: [ ]/ERROR


5.
main()
{
cout <<"hello";
main();
}
OUTPUT :[ ] /ERROR

6.
main()
{
int i=0;
for ( ; i++; cout<<i )
{cout<< i ; }
}

OUTPUT:[ ]/ERROR


7.
main()
{
static int i=++i;
static float j=++j;
cout<<i<<j;
}


OUTPUT : [ ]/ERROR

8.
main()
{ int a= 0;int b = 20;char x =1;
if(a,b,x)
cout<<"hello";
else
cout<<bye;
}

OUTPUT: [ ]/ERROR
NAME: &
MOBILE: BRANCH: SEMESTER:
*NO NEGATIVE MARKING

9.
main()
{
int i=5,j=6;
printf("%d",i+++j);
}

OUTPUT: [ ]/ERROR

10.
void abc(char a[])
{ a++;
cout<<*a;
cout<<++*a;
}

main()
{ char a[]={'a','b','f','d'};
abc(a);
}

OUTPUT: [ ]/ERROR


11.
main()
{
char a[]="12345\0";
int i=strlen(a);
cout<<++i;
}

OUTPUT: [ ]

12.
void fun()
{
here:
cout<<" : -D";
}
main()
{
int i=1;
while (i<=5)
{
cout<<i;
if (i>2)
goto here;
i++;
}}

OUTPUT: [ ]/ERROR

13.
main()
{ int i=1,j=2;
switch(i)
{ case 1: cout<<"GOOD";
break;
case j: cout<<"BAD";
break;
}
}


OUTPUT: [ ]/ERROR

14.
main()
{
Cout<<"\nab";
Cout<<"\bsi";
Cout<<"\rha";
}
OUTPUT:
a)abi
ha
b)asi
ha
c)hai
d)abiah

15.
.Which operator has the highest priority
a) ++
b) %
c) +
d) /
16.
Which of the following, if any, are valid
names for variables?
A. class
B. friend
C. #OnHand
D. void
E. None of the above is valid names for
variables



17.
char buf [] = "Hello world!";
char * buf = "Hello world!";
In terms of code generation, how
do the two definitions of buf, both
presented above, differ?

1. The first definition certainly
allows the contents of buf to be
safely modified at runtime; the
second definition does not

2. The first definition is not suitable
for usage as an argument to a
function call; the second
definition is.

3. They do not differ -- they are
functionally equivalent.

4. The first definition does not
allocate enough space for a
terminating NUL-character, nor
does it append one; the second
definition does.

18.
penny = one
nickel = five
dime = ten
quarter = twenty-five
How is enum used to define the values
of the American coins listed above?

1.enum coin {(penny,1), (nickel,5),
(dime,10), (quarter,25)};

2.enum coin ({penny,1}, {nickel,5},
{dime,10}, {quarter,25});

3.enum coin
(penny=1,nickel=5,dime=10,quarter=2
5);

4.enum coin {penny, nickel, dime,
quarter} (1, 5, 10, 25);

19.
The break statement causes an exit

1.from the innermost loop only
2.only from the innermost switch.
3.from all loops and switches
4.from the innermost loop or switch.

20.
cout is a/an __________ .

A. operator
B . function
C. object
D. macro

21..
Which of the following ways are legal to
access a class data member using this
pointer?
A. this->x
B. this.x
C. *this.x
D. *this-x

22.
main()
{ int a, b;
int* c;
c = &a;
a = 200;
b = 200;
*c = 100;
b = *c;
cout << *c << " " << b;
}

a) 100 200
b) 100 0
c) 200 200
d) 100 100

23.
main ()
{ int a;
int * ptr_b;
int ** ptr_c;
a = 1;
ptr_b = &a;
ptr_c = &ptr_b;
cout << a << " ";
cout << *ptr_b << " ";
cout << *ptr_c << " ";
cout << **ptr_c << " ";
}
a) 1 1 0xbffc9924 1

b) 1 1 1 0xbffc9924

c) 1 0xbffc9924 1 1

d) none of the mentioned

24.
main()
{ int array[] = {10, 20, 30};
cout << -2[array];
}
a) -15
b) -30
c) compile time error
d) garbage value

25.
main()
{ int c=11 & 6 ;
cout<<c;
}

a)0
b)1
c)2
d)none of the mentioned


26 .
main()
{
int x = 0;
for (x=1; x<4; x++) ;
cout<<x;
}

What will be printed when the sample
code above is executed?

1. x=0
2. x=1
3. x=3
4. x=4
5. x=5
27.
How many number of spaces should be
set in default tab?
a) 5
b) 8
c) 4
d) 6

28.
If the two strings are identical, then
strcmp() function returns

A. -1
B. 1
C. 0
D. Yes

29.
Which function in c++ will take large
objects?
a) string
b) class
c) vector
d) None of the mentioned

30.
How will you print \n on the screen?

A. cout<<"\n";
B. printf("\n");
C. cout<<'\n';
D. cout<<"\\n";

31.
Which of the following is not a correct C++
comment?

a) /*comment*/

b) //*comment*\

c) /*//comment*\

d) /*//comment/*/


32.
which of the following is incorrect for
statement

a. for(x=0; ;x++)

b. for(x=0,y=0;x!=y; x++,y--)

c. for(;x<99;x++)

d. all of the above are correct

33.
What is the output of the following
code?

int num=10;
int main()
{
int num=num;
cout<<num;
return 0;
}

a. 0

b. 10

c. NULL

d. Compiler error

You might also like