C Programming Practice Set II (75 Questions)

01. What error would the following function give on compilation

f(int a,int b) { int a; a=20; return a; }

02. What would be the output of the following program

main() { int a=10; void f(); a=f(); printf("%d",a); } void f() { printf("hi"); }

03. What is the output of the following program

main() { int b; b=f(20); printf("%d",b); } int f(int a) { a > 10 ? return(40) : return(50); }

04. How many times the string will be printed

main() { printf("I have one brother"); main(); }

05. What would be the output of the following program

#define SQR(x) x*x main() { int a; a=SQR(b+2); printf("%d",a); }

06. What is the output of the following program

#define CUBE(x) (x*x*x) main() { int a,b=3; a=CUBE(++b); printf("%d %d",a,b); }

07. What is the type of the variable abc according to the following definition

#define FLOATPTR float * FLOATPTR xyz,abc;

08. Which of the following is true

09. What is the output of the following program

#define BUS Train main() { printf("BUS"); }

10. The following program results in

#define LOOP while(1) main() { LOOP printf("Hi"); }

11. What is the output of the following program

#define MAX(a,b) (a>b?a:b) main() { int x; x=MAX(4+2,3+8); printf("%d",x); }

12. What is the output of the following program

#define PRINT(int) printf("%d",int) main() { int x=2, y=3, z=4; PRINT(x); PRINT(y); PRINT(z); }

13. What is the output of the following program

main() { printf("BBC ""world"); }

14. What is the output of the following program

#define str(x) #x #define hstr(x) str(x) #define proper divide main() { char *name = hstr(proper); printf("%s",name); }

15. What is the output of the following

#define sum(xy) printf("f%xy",f,xy) main() { float a=3.5,b=5; sum(a+b); }

16. What is the output of the following program

#define combine(s1,s2) s1 ## s2 float totalsales=2.5; printf("%f",combine(totalsales));

17. What is the output of the following program

main() { printf("%c", 'neelesh'); }

18. Which of the following is true

19. What would be the output of the following program

main() { char a[]="neelesh"; printf("%d %d",sizeof(a),sizeof(a)); }

20. What would be the output of the following program, if the array begins at address 5000.

main() { int abba[] = {6,4,7,3,3}; printf("%u %d",abba,sizeof(abba)); }

21. What would be the output of the following program

main() { float ff[20]={5,4,6}; printf("%u %u",ff,&ff); }

22. What would be the output of the following program, if the array begins at the address 6000

main() { int abc[] = {3,4,5,4}; printf("%u %u",abc+1,&abc+1); }

23. What would be the output of the following program

main() { int i[]="hello"; a="no hello"; printf("%d",strlen(a)); }

24. What would be the output of the following program

main() { double x[]={2.3,3.4,4.4,5}; printf("%d",sizeof(x)/sizeof(x[1])); }

25. What would be the output of the following program, if the array begins at the address 8000

main() { int b[3][4] = { 4,3,2,5,6,3,2,7,7,6,5,4}; printf("%u %u",b+1,&b+1); }

26. What is the output of the following program

main() { printf("kishore"+2); }

27. What is the output of the following program

main() { char s1[]="right",s2[]="right"; if(s1==s2) printf("yes"); else printf("no"); }

28. What would be the output of the following program in C

main() { char xyz[4]="Bahu"; printf("%s",xyz); }

29. What is the output of the following program

main() { int k=5; printf("%d %d",k,<=30,k=80); }

30. What is the output of the following

main() { char ch='a'; printf("%d %d %d",ch,sizeof('a'),sizeof("hello")); }

31. What would be the output of the following program

main() { printf("%c","jayaram"[5]); }

32. What is the output of the following program

main() { struct student { char *x; int age; }; struct student s1 = {"mahesh",21}; struct student s2=s1; printf("%s %d",s2.x); }

33. What is the output of the following program

main() { struct student { char *x; int age; }; struct student s1 = {"mahesh",21}; struct student s2=s1; if(s1==s2) printf("hello"); }

34. Which of the following is false

35. What is the output of the following program

main() { union a { int x; char ch[2]; }; union a z1={2,3}; printf("%d %d",z1.x); }

36. What is the output of the following program

main() { int k=9; const int *ptr; ptr=k; ptr=ptr-10; printf("%d",*ptr); }

37. What is the output of the following program

main() { int k=9; const int *ptr; ptr=k; printf("%d",*ptr); }

38. Choose the correct answer

39. Which is true about conditional compilation

40. C was primarily developed as

41. C is a

42. The variables which can be accessed by all modules in a program are known as

43. In what kind of storage structure for strings, one can easily insert, delete, concatenate and rearrange substrings

44. The variables which can be accessed by all modules in a program are known as

45. In what kind of storage structure for strings, one can easily insert, delete, concatenate and rearrange substrings

46. What would be the output of the following program

main() { int i=1,j=0x20,k,l,m; k=i | j; l=i & j; m=i^j; printf("%d %d %d",i,j,k,l,m); }

47. What is the output of the following program

main() { unsigned int m=32; printf("%x",~m); }

48. Which of the following is false

49. What is the output of the following program

main() { unsigned int a=0xfffff; printf("%x",~a); }

50. What would be the output of the following program

main() { unsigned char i=0x80; printf("%d",i<<1); }

51. What is the output of the following program

main() { printf("%x",~(-1>>4)); }

52. If the definition is given in the following way which is false

#define xyz char * xyz a,b;

53. What would be the output of the following program

main() { int y=128; const int x=y; printf("%d",x); }

54. What is the output of the following program

main() { int get() { return(30); } const int x=get(); printf("%d",x); }

55. What would be the output of the following program

main() { const int x=5; int *ptr; *ptr= &x; *ptr=10; printf("%d",x); }

56. What would be the output of the following program

main() { struct student { char rollno : 5; char name[20] : 6; }; printf("%d",sizeof(struct student)); }

57. Which of the following is false about bit fields

58. What is the output of the following program

main() { float b=6.15529; printf("%6.2f",b); }

59. What is the output of the following program

main() { float d=8.7; printf("%0.0f",d); }

60. What is the output of the following program

#include <stdio.h> main() { FILE *fp; fp=fopen("xyz","r"); }

61. What is the output of the following program

main() { int x=4; printf("%d %d",x,x); }

62. Which of the following statement is true

63. Which of the following statement is true

64. The maximum combined length of the command line arguments including the spaces between adjacent arguments is

65. If the program (xyz) is run from the command line as xyz red green blue What is the output

main(int argc,char *argv[]) { while(argc) printf("%s",*argv++); }

66. What is the output of the following program

main() { const int x=5; int *ptr; *ptr= &x; ptr=10; printf("%d",x); }

67. In what kind of storage structure for strings, one can easily insert, delete, concatenate and rearrange substrings

68. What is the time complexity of linear search algorithm over an array of n elements

69. What is the time taken by binary search algorithm to search a key in a sorted array of n elements

70. What is the time required to search are element in a linked list of length n

71. What is the worst case time required to search a given element in a sorted linked list length n

72. Consider a linked list of n elements. What is the time taken to delete the element which is the successor of the element pointed to by a given pointer

73. Consider a linked list of n elements. What is the time taken to insert an element after an element pointed to by some pointer

74. Which of the following operations is performed more efficiently by doubly linked list than by linear linked list

75. Which data structure is needed to convert infix notations to postfix notation