Sunteți pe pagina 1din 14

Q.

7) Which of the following is the correct output for the


program given below ?
#include<stdio.h>
int main()
{
int arr[3]={2,3,4};
char *p;
p=arr;
p=(char*)((int*)(p));
printf("%d",*p);
p=(int*)(p+1);
printf("%d\n",*p);
return 0;
}
A) 2 3 4
B) 2 0
C) 2
D) Garbage values
--------------------------------------------Q.8) Which of the following is the correct output for the
program given below?
#include<stdio.h>
int main()
{
void *vp;
char ch=74,*cp="JACK";
int j=65;
vp=&ch;
printf("%c",*(char*)vp);
vp=&j;
printf("%c",*(int*)vp);
vp=cp;

printf("%s\n",(char*)vp+2);
return 0;
}
A)
B)
C)
D)

JCK
J65K
JAK
JACK

---------------------------------------------------------Q.9) Which of the following is the correct output for the


program given below ?
#include<stdio.h>
void fun(void *p)
int i;
int main()
{
void *vptr;
vptr=&i;
fun(vptr);
return 0;
}
void fun(void *p)
{
int **q;
q=(int**)&p;
printf("%d\n",**q);
}
A) Error:Cannot convert from void ** to int**
B) Garbage value
C) 0
D) No output
---------------------------------------------------

Q.10) Which of the following is the correct output for the


program given below?
#include<stdio.h>
int main()
{
int i,*j,k;
i=3;
j=&i;
printf("%d\n",i**j*i+*j);
return 0;
}
A) 30
B) 27
C) 9
D) 3
------------------------------------------------------------Q.11) Which of the following is the correct output for the
program given below?
#include<stdio.h>
int *check(static int,static int);
int main()
{
int *c;
c=check(10,20);
printf("%d\n",*c);
return 0;
}
int *check(static int i,static int j)
{
int *p,*q;
p=&i;

q=&j;
if(i>=45)
return(p);
else
return(q);
}
A) 10
B) 20
C) Error: 'Non portable pointer conversion'
D) Error: 'Cannot use static for function parameters'
------------------------------------------------------------------------Q.12) Which of the following statement is correct about k
used in the statement given below ?
char****k;
A)
B)
C)
D)

k is pointer to a pointer to a pointer to a char


k is pointer to a pointer to a pointer to a pointer to a char
k is pointer to a char pointer
k is pointer to a pointer to a char

---------------------------------------------------------------------------------Q.13) Which of the following statements correctly declare a


function that receives a pointer to a pointer to a pointer to a
float and returns a pointer to a pointer to a pointer to a
pointer to a float ?
A)
B)
C)
D)

float** fun(float ***);


float* fun(float ***);
float fun(float ***);
float **** fun(float ***);

----------------------------------------------------------------------

Q.14) Which of the following statements is correct about the


program given below ?
int main()
{
int arr[3][3] = {1,2,3,4};
printf("%d\n",*(*(*(arr))));
return 0;
}
A)
B)
C)
D)

It will output a garbage value


It will output a value 1
It will output a value 1
It will report an error: 'Invalid indirection'

-----------------------------------------------------------------------Q.15) Which of the following statement is true about the


program given below ?
#include<stdio.h>
int main()
{
float a=3.14;
char *j;
j=(char *)&a;
printf("%d\n",*j);
return 0;
}
A) It will print ASCII value of the binary number present in
the first byte of the float variable a.
B) It will print character equivalent of the binary number present
int the first byte of the float variable a.
C) It will print 3.
D) It will print a garbage value

-------------------------------------------------------------------------Q.16) Which of the following statement is true about the


program given below ?
#include<stdio.h>
power(int**);
int main()
{
int a=5,*aa; /* Suppose the address of the variable a is 1000
*/
aa=&a;
a=power(&aa);
printf("%d\n",a);
return 0;
}
power(int **ptr)
{
int b;
b=**ptr***ptr;
return(b);
}
A)
B)
C)
D)

5
25
125
Garbage value

---------------------------------------------------Q.17) What will be the output of the following program if the


size of the
pointer is considered as 4 bytes ?
#include<stdio.h>

int main()
{
printf("%d %d\n",sizeof(NULL),sizeof(**));
return 0;
}
A) 00
B) 01
C) 11
D) 41
-------------------------------------------------------------------Q.18) Which of the following is the correct output for the
program given below?
#include<stdio.h>
int main()
{
int i;
char a[]="\0";
if(printf("%s",a))
printf("String is not empty\n");
else
printf("The string is empty\n");
return 0;
}
A) The string is not empty
B) The string is empty
C) No output
D) 0
----------------------------------------------------------------------Q.19) Which of the following is the correct output for the

program given below?


#include<stdio.h>
int main()
{
char str1[]="Hellow";
char str2[]="Hellow";
if(str1==str2)
printf("Equal\n");
else
printf("Unequal\n");
return 0;
}
A)
B)
C)
D)

Equal
Unequal
Error
None of the above

------------------------------------------------------------------------Q.20) Which of the following is the correct output for the


program given below?
#include<stdio.h>
int main()
{
printf("Icecream""Chocolate pie\n");
return 0;
}
A)
B)
C)
D)

Error
Icecream chocolate pie
Icecream
Chocoloate pie

-----------------------------------------------------------------------Q.21) Which of the following is the correct output for the


program given below?
#include<stdio.h>
#include<string.h>
int main()
{
char str1[20]="Hell0",str2[20]="Word";
printf("%s\n",strcpy(str2,strcat(str1,str2)));
return 0;
}
A)
B)
C)
D)

Hello
World
Hello World
WorldHello

------------------------------------------------------------------------Q.21) Which of the following is the correct output for the


program given below?
#include<stdio.h>
int main()
{
int i;
char a[]="\0";
if(printf("%s",a))
printf("The string is not empty\n");
else
printf(''The string is empty\n");
return 0;
}

A)
B)
C)
D)

The string is not empty


The string is empty
No output
0

------------------------------------------------------------------------Q.22) Which of the following is the correct output for the


program given below?
#include<stdio.h>
int main()
{
char str1[]="Hello";
char str2[]="Hello";
if(str1==str2)
printf("Equal\n");
else
printf("Unequal\r");
return 0;
}
A)
B)
C)
D)

Equal
Unequal
Error
None of the above

-----------------------------------------------------------------------------------Q.22) Which of the following is the correct output for the


program given below ?
#include<stdio.h>
int main()
{
printf("Icecream""Chocolate pie\n");

return 0;
}
A)
B)
C)
D)

Error
Icecream Chocolate pie
Icecream
Chocolate pie

-------------------------------------------------------------------------------------Q.23) Which of the following is the correct output for the


program given below ?
#include<stdio.h>
#include<string.h>
int main()
{
chr str1[20]="Hello",str2[20]="World";
printf("%s\n",strcpy(str2,strcat(str1,str2)));
return 0;
}
A)
B)
C)
D)

Hello
World
Hello World
WorldHello

-----------------------------------------------------Q.24) Which of the following is the correct output for the


program given below ?
#include<stdio.h>
int main()
{
char str[]="sales\0man\0";
printf("%d\n",sizeof(str));

return 0;
}
A)
B)
C)
D)

10
6
5
11

-----------------------------------------------Q.25) Which of the following is the correct output for the


program given below ?
#include<stdio.h>
int main()
{
Union a
{
Int I;
Char ch[2];
};
Union a u1 = {512};
Union a u2 = (0,2);
Return 0;
}
A)
B)
C)
D)

u2 CANNOT be initialized as shown


u1 can be initialized as shown.
To initialize char ch[] of u2 . Operator should be used.
All above

Q.26) Which of the following is the correct output for the


program given below ?
#include<stdio.h>

int main()
{
Struct byte
{
Int one:1;
};
Struct byte var = {1};
Printf(%d\n,var.one);
Return 0;
}
A)
B)
C)
D)

1
-1
0
Error

Q.27) Which of the following is the correct output for the


program given below ?
#include<stdio.h>
int main()
{
Union a
{
Int i;
Char ch[2];
};
Union a u;
u.ch[0]=3;
u.ch[1]=2;
printf(%d%d%d\n,u.ch[0],u.ch[1],u.i);
return 0;
}
A) 3 2 515

B) 515 2 3
C) 3 2 5
D) None of the above
Q.27) Which of the following is the correct output for the
program given below ?
#include<stdio.h>
int main()
{
Unsigned int num;
Int c=0;
Scanf(%u,&num);
for(;num;num>=1)
{
If(num &1)c++;
}
Printf(%d\n,c);
Return 0;
}
A)It counts the number of bits that are on in the number num.
B) It sets all bits in the number num to 1.
C) It sets all bits in the number num to 0
D) None of the above

S-ar putea să vă placă și