C programming language questions

1.For the following program.

struct XXX {

int a; float b; char *s; }X;

If optimization :X not used in compiler then unused bits_________________. Give your assumption_______________.

2. Give the output of the following program

struct XXX {int a:6; float b:4; char s; }structure;

size of (structure);

3.Class used for the multiple inheritance in JAVA_________________

anonymous class (b) inner class (c) abstract class (d) none

4.. Write one statement equivalent to the following two statements: x=sqr(a); return(x); Choose from one of the alternatives (a) return(sqr(a)); (b) printf("sqr(a)"); (c) return(a*a*a); (d) printf("%d",sqr(a));

5. Which of the following about the C comments is incorrect? (a) Comments can go over multiple lines (b) Comments can start any where in the line (c) A line can contain comments with out any languagestatements (d) Comments can occur within comments

6. Given definition for a function which returns a array of pointers with argument of int*.

7. Give a function declaration with no arguments which refers a two dimensional array

8. Pick up the correct function declaration.

1.void *[] name(); 2. void int[][] name(); 3. void ** name(); 4. none of the above.

9. Read the function conv() given below conv(int t) { int u; u=5/9 * (t-32)

return(u);

}

What is returned (a) 15 (b) 0 (c) 16.1 (d) 29

10. Which of the following represents true statement either x is in the range of 10 and 50 or y is zero (a) x >= 10 && x <= 50 y = = 0 (b) x<50 (c) y!=10 && x>=50 (d) None of these

11. Which of the following is not an infinite loop ? (a) while(1)\{ ....} (b) for(;;){...} (c) x=0; (d) # define TRUE 0 do{ /*x unaltered within the loop*/ ... .....}while(x = = 0); while(TRUE){ ....} 12. What does the following function print? func(int i) { if(i%2)return 0; else return 1; } main() { int =3; i=func(i); i=func(i); printf("%d",i); } (a) 3 (b) 1 (c) 0 (d) 2

13. What is the value of y in the following code? x=7; y=0; if(x=6) y=7; else y=1; (a) 7 (b) 0 (c) 1 (d) 6

14. Read the folllowing code # define MAX 100 # define MIN 100 .... .... if(x>MAX) x=1; else if(x<MIN) x=-1; x=50; if the initial value of x=200,what is the value after executing this code? (a) 200 (b) 1 (c) -1 (d) 50

15. Give the output of the following program

main() {char *s; s="hot java"; strcpy(s,"solarrs java") }

16. Give the output of the following program

main() {printf("hot java"); fork() exit(0); }

(i). When redirected to a screen what will be printed. (ii). When redirected to file what will be printed.

17. Give the output of the following program

main() {int ret; ret=fork();ret=fork();ret=fork();ret=fork(); if(!ret) printf("sun"); else printf("solaris");

18. Give the output of the following program

main() {char *p='a'; int *i=100/*p; }

what will be the value of *i= 1

19. Which data structure gives efficient search?

1 B-tree

2 binary tree 3 array 4 linked list

20. Find the error in the

following program

struct point {struct point *next; int data; } x;

main() {int i; for(x=p;x!=0;) x=x->next,x++; freelist(x); }

freelist(x) {free(x); return }

21. Consider the following

structure: struct num nam { int no; char name[25]; } struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}}; ..... ..... printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1); What does the above statement print? (a) 8,9 (b) 9,9 (c) 8,8 (d) 8,unpredictable value

22. Identify the in correct expression (a)a=b=3=4; (b)a=b=c=d=0; (c)float a=int b= 3.5; (d)int a; floatb;a=b=3.5;

No comments: