C Programming Fundamentals
Test your knowledge of C programming concepts including pointers, arrays, memory allocation, and control structures
Questions
void main() { int a=10,b=20; char x=1,y=0; if(a,b,x,y) { printf("EXAM"); } }
- XAM is printed
- exam is printed
- Compiler Error
- Nothing is printed
What is the result of 16>>2? 1) 4 2) 8 3) 3 4) 0
- 4
- 8
- 3
- 0
What is the output of the following code? #include<stdio.h>void main(){char letter =Z;printf("\n%c",letter);}
- Z
- 90
- Error
- Garbage Value
What is the output of the following code? #include<stdio.h>void main(){ int s=0; while(s++<10) { if(s<4 && s<9) continue; printf("\n%d\t",s); }}
- 1 2 3 4 5 6 7 8 9
- 1 2 3 10
- 4 5 6 7 8 9 10
- 4 5 6 7 8 9
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 }
- 10..10
- 10..50
- Error
- 0
Array passed as an argument to a function is interpreted as
- Address of the array
- Values of the first elements of the array
- Address of the first element of the array
- Number of element of the array
How can I dynamically allocate a two-dimensional array?
- int **array1 = (int **)malloc(nrows * sizeof(int *));
- int **array2 = (int **)malloc(nrows * sizeof(int *));
- int *array3 = (int *)malloc(nrows * ncolumns * sizeof(int));
- Any of the above.
main() { char thought[2][30]={"Don`t walk in front of me..","I am not follow"}; printf("%c%c",(thought[0]+9),(*(thought+0)+5)); } What is the output of this program?
- k k
- Don`t walk in front of me
- I may not follow
- K
#include <stdio.h>void main() { int I=3,*j,**k; j=&I; k=&j; printf("%d%d%d",*j,*k,(*k)); } What is the output of the above program code?
- 444
- 000
- 333
- 433
Which of the following is the correct way of declaring a float pointer:
- float ptr;
- float *ptr;
- *float ptr;
- None of the above
The five items: A, B, C, D and E are pushed in a stack,one after the other starting from A. The stack is popped four times and each element is inserted in a queue. Then two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is.
- A
- B
- C
- D
What is the output of the following code? #include<stdio.h> void main() { int a=0,b=0; a = (b = 75) + 9; printf("\n%d, %d",a, b); }
- 75, 9
- 75, 84
- 84, 75
- None of these options