Você está na página 1de 7

SDM College Of Engg And Tech,Dharwad

Dept Of Computer Science


C Objective Test
PART A
TIME DURATION : 60 mins
1) main(){
char *p;
p="%d\n";
p++;
p++;
printf(p-2,300);}
compiler error b)300

c)Garbage value d)none of these

ans b
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------3)main(){
int a= 0;int b = 20;char x =1;char y =-1;
if(a,b,x,y)
printf("hello");
else
printf( world\n );}
a) hello b) world c) compiler error d) helloworld
ans :c
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------5)What is the output of this program ?
Union tag
{
int a;
char x,y;
}name;
(Assume storage is Little Endian technique)
int main() {
name.a=258;
printf( \n x=%d
y=%d ,name.x,name.y); }
a) x=1 y=1 b) x=2 y=2
c) x=1 y=2
d) error
--------------------------------------------------------------------------------------------------------------6)main() {
int i,k,l;
printf("%d",scanf("%d%d%d",&i,&k,&l));
}
what will be the output if, 0, 4, a are entered
a)0 b)2
c)3
d)none of these
---------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------8)#include<stdio.h>
main() {
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32); }
a)L
ans : M (77)

b)M

c)N

d)O

--------------------------------------------------------------------------------------------------------------9)#include<stdio.h>
main() {
struct xx {
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d\n",s->x);
printf("%s",s->name); }
a)3 and hello b) compiler error

c)linker error d)none of these

ans: b
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------11)main()
{ int i=100000000097;
printf("%d %c\n",i,i); }
a)97,a b)unpredictable,a
c)97,unpredictable
d)compile time e
rror
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------13)What is the output of the Program?
main(){
int a = 1;
#define p a;
printf("%d.. %d",a++,p++); }
a) 1..0
b)2..0 c)1..2 d)none of these
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------15) main(){
float a = 5.375;
char *p;
int i;

p=(char *)&a;
for(i=0;i<=3;i++)
printf("%02x",(unsigned char)p[i]); }
a)00 00 ac 40 b)00 ff ff 05 c)compiler error
d)run time error
saying illegal pointer conversion
--------------------------------------------------------------------------------------------------------------16)# include<stdio.h>
aaa() {
printf("hi");
}
bbb(){
printf("hello");
}
ccc(){
printf("bye");
}
main()
{
int (*ptr[3])();
ptr[0]=aaa;
ptr[1]=bbb;
ptr[2]=ccc;
ptr[2]();
}
a)hihellobyebye
b)hihellobye
c)bye d)aaabbbcccbye
c: bye
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------18)struct point
{
int x;
int y;
};
struct point origin,*pp;
main()
{
pp=&origin;
printf("origin is(%d%d)\n",(*pp).x,pp->y);
}
a)origin is(garbage values)
b)variables not initialized
c)origin is(0,0)
d)none of these
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------20)What is the difference between ++*ip and *ip++ ?
a) both increment value
b) ++*ip increment value and *ip++ increment address
c) both increment address
d) ++*ip increment address and *ip++ increment value
---------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------22) #define square(x) x*x


main()
{
int i;
i = 64/square(4);
printf("%d",i);
}
a)4

b)64

c)16

d)256

ans: c
--------------------------------------------------------------------------------------------------------------23)#include<stdio.h>
#define FUN(i,j) i##j
void main() {
int val1=10;
int val12=20;
printf( %d ,FUN(val1,2)); }
a) 10 b) 20 c) 1020 d) 12
--------------------------------------------------------------------------------------------------------------24)main() {
int i=0;
if(i++)
main();
{
printf( f );
exit(0);}
main();
}
a)f
b)f f f f f
c)run time error
d)compiler time error
--------------------------------------------------------------------------------------------------------------25)main()
{
char *p;
int *q;
long *r;
p=q=r=0;
p++;
q++;
r++;
printf("%p...%p...%p",p,q,r);
}
a)0001 0001 0001
b)0001 0002 0004
c)1 1 1 d)compiler error
--------------------------------------------------------------------------------------------------------------26)What is the output of the program.
main() {
printf("%d\n", f(7));
}
f(int x)
{
if (x <=4)

return x;
else
return (f(x--));
}
(a) 4 (b) 5 (c) 7 (d) infinite loop
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------28)main() {
int i;
i = abc();
printf("%d",i);
}
abc()
{
_AX = 1000;
}
a)1000 b) compiler error
c)Garbage value d) none of these
--------------------------------------------------------------------------------------------------------------29)void main() {
static int i=5;
printf( %d ,i--);
if(i)
main(); }
a)5 infinite times
b)5 4 3 2 1
c)run time error
d)unpredictable
--------------------------------------------------------------------------------------------------------------30)void main() {
char a[]="12345\0";
int i=strlen(a);
printf("here in 3 %d\n",++i); }
a)here in 3 5 b)here in 3 6 c)here in 3 7 d)none of these
--------------------------------------------------------------------------------------------------------------31)void main() {
unsigned giveit=-1;
int gotit;
printf("%u ",++giveit);
printf("%u \n",gotit=--giveit); }
a)0 -1 b)compile error c)0 garbage
d)0 65535
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------33)What is the output of the following code?
#include<stdio.h>
void swap(int&, int&);
void main() {
int a = 10,b=20;
swap (a++,b++);
printf("\n%d\t%d\t",a, b);
}

void swap(int& x, int& y)


{
x+=2;
y+=3; }
a) 14, 24
b) 11, 21
c) 10, 20
d) Error
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------36)main() {
unsigned int i=65000;
while(i++!=0);
printf("%d",i); }
a)65000
b)65535
c)0
d)1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------38) Pushdown list means:
a) Stack
b) Queue
c) Linked list d) All of the above
--------------------------------------------------------------------------------------------------------------39)#if something = = 0
int some=0;
#endif
main() {
int thing = 0;
printf("%d %d\n", some ,thing); }
a)0 0 b)garbage 0
c)undefined variable
d)syntax error
--------------------------------------------------------------------------------------------------------------40)What is the output for the following program
main() {
int arr2D[3][3];
printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }
a)1
b)0
c)compile error
d)run time error
--------------------------------------------------------------------------------------------------------------*41)main ( ) {
static char *s[ ] = { black , white , yellow , violet };
char **ptr[ ] = {s+3, s+2, s+1, s}, ***p;
p = ptr;
**++p;
printf( %s ,*--*++p + 3); }
a)black
b)violet
c)ck
d)et
--------------------------------------------------------------------------------------------------------------42)What is the output of the following code?
# include<stdio.h>

# define a 10
main() {
printf("%d..",a);
foo();
printf("%d",a); }
void foo() {
#undef a
#define a 50 }
1) 10..10
2) 10..50
3) Error
4) 0
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------45)main() {
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }
a)5 5 5 b)4 4 4 c)2 4 4 d)none of these
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------***********ALL THE BEST********

Você também pode gostar