C-language 63 programming Questions


                                                                     

C-language 63 programming Questions

1. What are storage classes in 'C' language? a)auto keyword b)static keyword c)register keyword d)extern keyword e)automatic f)static 2. What are the storage class specifiers in c language? 3. How many variables scopes are there in c language? 4. main() { int i; for(i=0;i<5;i++) { static int a=0; int b=0; a++; b++; printf("\na=%d",a); printf("b=%d",b); } } 5. main() { static int s; ++s; printf("\n%d",s); if(s<=3) main(); printf("\n%d",s); } 6. extern int a; main() { printf("\na=%d",a); return 0; } 7. int a; main() { printf("\na=%d",a); return 0; } 8. extern int a; main() { printf("\na=%d",a); return 0; }int a; 9. extern int a; main() { printf("\na=%d",a); return 0; } int a=5; 10. extern int a=5; main() { void fun(); printf("\n a=%d",a); fun(); return 0; } int a; void fun() { printf("\n in function a=%d",a); } 11. extern int a; main() { void fun(); printf("\n a=%d",a); fun(); return 0; } int a=7; void fun() { printf("\n in function a=%d",a); } 12. void fun(int _) { printf("%d",_); } main() { fun(23); return 0; } 13. void fun(auto int _) { printf("%d",_); } main() { fun(23) return 0; } 14. void fun(static int _) { printf(*"%d",_); } main() { fun(23); return 0; } 15. void fun(extern int _) { printf("%d",_); } main() { fun(23); return 0; } 16. void fun(register int _) { printf("%d",_); } main() { fun(23); return 0; } 17. void fun(typedef int _) { printf("%d",_); } main() { fun(23); return 0; } 18. main() { auto a; register r; static s; extern e; printf("\n%d",sizeof(a)); printf("\n%d",sizeof(r)); printf("\n%d",sizeof(s)); printf("\n%d",sizeof(e)); return 0; } 19. static extern int a=5; static int b=6; main() { printf("\n%d",a); printf("\n%d",b); return 0; } 20. main() { extern int a=5; prinitf("\n%d",a); return 0; } 21. Is it possible to declare static function in c language? 22. Can we return more than one value by using return statement? 23. How to return more than one value from a function? 24. Can we use more than return statement in one function? 25. Give an example for function returning void but contains return statement? 26. What is the differences between K&R C style and ANSI C style? 27. Write a small c function to receive any number of arguments? 28. main() { int *p1; float *p2; double *p3; char *p4; printf("\n%u",sizeof(p1)); printf("\n%u",sizeof(p2)); printf("\n%u",sizeof(p3)); printf("\n%u",sizeof(p4)); return 0; } 29. main() { int far *p1; float far *p2; double far *p3; char far *p4; printf("\n%u",sizeof(p1)); printf("\n%u",sizeof(p2)); printf("\n%u",sizeof(p3)); printf("\n%u",sizeof(p4)); return 0; } 30. main() { int *p; int a=5; *p++; printf("%d",a); return 0; } 31. main() { int *p; int a=5; ++*p; printf("%d",a); return 0; } 32. main() { char *p; int a=-1; p=(char *)&a; *p=0; printf("%d",a); return 0; } 33. main() { int *p; p=(int *)100; p=p+1; printf("%u",p); return 0; } 34. main() { float *p; p=(float *)100; p=p+1; printf("%u",p); return 0; } 35. main() { int *p; p=(int *)100; p=p*1; printf("%u",p); return 0; } 36. main() { int *p,*q; p=(int *)100; q=(int *)200; p=p+q; printf("%u",p); return 0; } 37. main() { int *p,*q; p=(int *)100; q=(int *)200; printf("%u",q-p); return 0; } 38. main() { float *p,*q; p=(float *)100; q=(float *)200; printf("%u",q-p); return 0; } 39. main() { void *p; void far *q; printf("\n%u ",sizeof(p)); printf("\n%u",sizeof(q)); return 0; } 40. main() { void a; printf("\n %u",sizeof(a)); } 41. main() { const int a=5; printf("\n%d",a); a++; printf("\n%d",a); return 0; } 42. main() { int *p; const int a=5; p=&a; *p=6; printf("%d",a); return 0; } 43. main() { int *p; const int a=5; p=&a; *p=6; printf("%d",a); return 0; } 44. main() { int a=5; const int *p=&a; *p=6; printf("%d",*p); return 0; } 45. main() { int a=5; const int *p=&a; *p=6; printf("%d",*p); return 0; } 46) main() { int a=5; int const *p=&a; *p=6; printf("%d",*p); return 0; } 47) main() { int const *p=(int *)100; p++; printf("%u",p); return 0; } 48) main() { int *const p=(int *)100; p++; printf("%u",p); return 0; } 49) main() { int a=89; int p; p=&a; *(int *)p=8; printf("\n a=%d",a); return 0; } 50) void f1() { int a=0; ++a; printf("\n%d",a); } main() { int a=10; f1(); f1(); f1(); printf("%d",a); return 0; } 51) void f1() { static int s=5; ++s; printf("\n%d",s); } main() { f1(); f1(); printf("%d",s); } 52) void f1() { static int s=5; ++s; printf("\n%d",s); } main() { f1(); f1(); } 53) void abc(int a) { ++a; } void main() { int a=10; abc(); abc(); printf("%d",a); } 54) void abc(int a) { ++a; } void main() { int a=10; abc(a); abc(a); printf("%d",a); } 55) void f1() { extern int g; static int s=5; int a; ++g; a=s++; printf("\n%d%d%d",a,s,g); if(a<=6) f1(); printf("\n%d%d%d",a,s,g); } void f2() { static int s; int a; a=++s; ++g; printf("\n%d%d%d",a,s,g); if(a<=2) f2(); printf("\n%d%d%d",a,s,g); } main() { f1(); f2(); } 56) void abc(int a) { ++a; printf("\n%d",a); } void main() { int a=10; abc(++a); abc(a++); printf("%d",a); } 57) void abc(int a,int b) { printf("\n%d%d",++a,++b); } void main() { int a=10; abc(++a,a++); abc(a++,++a); printf("%d",a); } 58) void xyz(int p1,int *p2) { ++p1; ++*p2; printf("\n%d%d",p1,*p2); } void main() { int a=10; xyz(a++,&a); xyz(++a,&a); printf("\n%d",a); } 59) void xyz(int p1,int *p2) { ++p1; ++*p2; printf("\n%d%d",p1,*p2); } void main() { int a=10; xyz(a++,++*(&a)); xyz(++a,*(&a)); printf("\n%d",a); } 60) void xyz(int p1,int *p2) { ++p1; ++*p2; printf("\n%d%d",p1,*p2); if(p1<=12) xyz(p1,p2); printf("\n%d%d",p1,*p2); } void main() { int a=10; xyz(a++,&a); xyz(a++,&a); printf("\n%d",a); } 61) void main() { int a=1; void xyz(int,int); xyz(++a,a++); xyz(a++,+++a); printf("\n%d",a); } void xyz(int x,int y) { printf("\n%d%d",x,y); } 62. void display(int a) { printf("\n%d",a); if(--a) display(a); printf("\n%d",a); } void main() { display(4); } 63. void xyz(int x) { printf("\n%d",x); if(x) xyz(x-1); printf("\n%d",x); } void abc(int a) { printf("\n%d",a); xyz(a); if(a) abc(a-1); printf("\n%d",a); } void main() { abc(2); }

Comments

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

PR, PN and PV Variable in Yocto