1.which of the following about the following two declarations is true i) int *F(); ii)int (*F)(); a)Both are identical b)the first is a correct declaration and second is wrong c)the first declaration is a function returning a pointer to an integer and the second is a pointer to a function returning int d)Both are different ways of declaring pointer to a function (ans. (c))
2.what are the values printed by the following program? #define dprintf(expr) printf("expr=%d\n”,expr) main() { int x=7; int y=3; dprintf(x/y); } a)#2=2 b)expr=2 c)x/y=2 d)none (ans.( c))
3.which of the following is true of the following program main() { char *c; int *ip; c=(char *)malloc(100); ip=(int *)c; free(ip); } a)the code functions properly by releasing all the memory allocated b)results in compilation error as a pointer of various types cannot be equated c)the program ties to free more memory than allocated and results in run time error d) works well except when the machine runs low on memory and malloc is unabel to allocate the memory (ans. (d))
5.which of the following is not an ANSI C language keyword? a)volatile b)function c)default d)const e)void (ans. (b))
6.when an array is passed as parameter to a function , which of the following statement is correct the function can change values in the original array in c parameters are passed by value the function cannot change the original value in the array it results in compilation error.Array cannot be passed as a parameter to a function results in runtime error when the function tries to access the elements in the array
7.the type of the controlling expression of a switch statement cannot be of the type a)int b)char c)short d)float e)none (ans.(d))
11.output: int x=0x65; main() { char x; printf(“%d\n”,x); } a) Compilation error b)’A’ c)65 d)undefined
12.output main() { int a=10; int b=6; if(a=3) b++; printf(“%d %d”,a,b++); } a)10,6 b)10,7 c)3,6 d)3,7 e)none
13.main() { enum months {jan=1,feb,mar,apr}; months x=jan; if(x==1) printf(“jan is the first month”); } a)does not print anything b)prints : jan is the first month c)generates compilation error d)results in runtime error (ans. (c))
14.what is the output of the following program? Main() { char *src=”hello world”; char dst[100]; strcpy(src,dst); printf(“%s”,dst); } strcpy(char *dst,char *src) { while (*src) *dst++=*src++; } a)”hello world” b)”hello” c)”world” d)NULL e)undefined (ans. (e))
15.main() { int i=6; switch(i) { default: i+=2; case 4;i=4; case 5:i++; break; } printf(“%d”,i); } a)8 b)6 c)5 d)4 e)none (ans. (c))
16.main() { int x=20; int y=10; swap(x,y); printf(“%d %d”,y,x+2); } swap(int x,int y) { int temp; temp=x; x=y; y=temp; } a)10,20 b)20,12 c)22,10 d)10,22 e)none
18.struct node{ char *word; int count; struct node left; struct node right; }; a)incorrect definiton b)structures cannot refer to other structrues c)structures can refer to themselves. Hence the statement is ok d)structures can refer to maximum of one other structure
19.what is the size of the following union union tag{ int a; float b; char c; }; a)2 b)4 c)1 d)7 (ans.(b))
20. main() { char s[]=”hello world”; printf(“%15.10s”,s); } a)hello,.world… b)…..hello world c)heloo,.wor….. d)none of the above (ans.(b))
hiy have mensioned that the ans for 13th ques as C.ie compilation error.but i think the prog run successfully and print jan is the first month(ie ans a)
any struct object cannot be declare in itself. because at compilation time compiler has to locate the memory to the struct bt if struct has its own object in it then it is difficult to find the size of the struct for compiler. pointer to own struct can be declare like
struct node{ char *word; int count; struct node *left; struct node *right; }; because pointer need only 2 byte what ever the type of pointer.
Nay. I dont think it works that way. I really dont know what compiler you been using. But with VC++ it sure does throw some errors. I would post those errors.