1. By which file function you can position the file pointer in accordance with the current position?
2. Which function will you use to write a formatted output to the file?
3. What will be printed on the standard output as a result of the following code snippet? void main() { int num1 = 30, num2 = 4; float result; result = (float)(num1/num2); printf('%.2f', result); return 0; }
4. What would be printed on the standard output as a result of the following code snippet? char *str1 = 'Hello World'; strcat(str1, '!'); printf('%s', str1);
5. What does the argv[0] represent?
6. Read the following two declaration statements. 1. #include 2. #include 'stdio.h' Which of the following statements pertaining to the above two statements are correct?
7. What will be the output of following code? int main() { int i; i = 0; for (i = 1; i <2; i++) { i++; printf( '%d', i ); continue; printf('%d', i ); } return 0; }
8. Which header file are methods(or macros) isalpha(), islower() a part of?
9. Which one is the correct way of initializing a two-dimensional array?
10. What will be printed on the standard output as a result of the following code snippet? int funr(int x, int y) { if(x <= 0) { return y; } else { return (1+funr(x-1,y)); } } void main() { printf('%d',funr(2,3)); }
11. Which file mode would mean read + append?
12. What will be the output of the following program? #include main() { int n = 5; assert(n > 3); //statement 1 n = n+2; assert(n > 7);//statement 2 return 0; }
13. What would be printed on the standard output as a result of the following code snippet? main() { int n=5, x; x = n++; printf('%d ', x); x = ++n; printf('%d ', x++); printf('%d', x); return 0; }
14. Which function will convert a string into a double precision quantity?
15. Which one is not a valid mode for opening a file?
16. What is the function to concatenate two strings?
17. What would be printed on the standard output as a result of the following code snippet? main() { enum {red, green, blue = 0, white}; printf('%d %d %d %d', red, green, blue, white); return 0; }
18. The declaration int (*p[5])() means:
19. Which statements is valid and correct?
20. What would be printed on the standard output as a result of the following code snippet? main() { int i=5; char option = 5; switch(option) { case '5': printf('case : 1 \n'); break; case i: printf('case : 2 \n'); break; default: printf('case : 3 \n'); break; } return 0; }
21. What will be printed on the standard output as a result of the following code snippet? void main() { int arr[][2] = {1,2,3,4,5,6}; printf('%d',arr[2][1]); }
22. Which one is not a storage type?
23. What is wrong with the following function prototype statement? int func();
24. Which of the following declarations of structures is/are valid? 1) struct node { int count; char *word; struct node next; }Node; 2) struct node { int count; char *word; struct node *next; }Node; 3) struct node { int count; char *word; union u1 { int n1; float f1; }U; }Node;
25. Which function is used to extract formatted input from a file?
26. What does the following function do? int fn(unsigned int x) { int count = 0; for(; x!=0; x&=(x-1)) count++; return count; }
27. What will be printed on the standard output as a result of the following code snippet? void func() { static int i = 1; int j = 1; i++; j++; printf('%d %d ',i,j); } void main() { func(); func(); func(); }
28. Select the correct statement about arrays.
29. Which standard function is used to close a file?
30. Which function allocates memory and initializes elements to 0?
31. What would be printed on the standard output as a result of the following code snippet? main() { char *pmessage = 'asdfgh'; *pmessage++; printf('%s', pmessage); return 0; }
32. What would be printed on the standard output as a result of the following code snippet? #define max(a, b)((a) > (b)?(a):(b)) main() { int a=4, c = 5; printf('%d ', max(a++, c++)); printf('%d %d\n', a,c); }
33. What would be printed on the standard output as a result of the following code snippet? main() { int a[5] = {1,4,5,6,9}; printf('%d\t', *a); //Line 1 printf('%d', *++a); //Line 2 return 0; }
34. What will happen when the following code is executed? void main() { char arr1[] = 'REGALINT'; char arr2[10] = 'REGALINT'; printf('%d,',sizeof(arr1)); printf('%d',sizeof(arr2)); }
35. What will be printed on the standard output as a result of the following code snippet? void main() { int arr[5]={1,2,3,4,5}; printf('%d\n', *(arr+4)); }
36. Given the following array: int a[8] = {1,2,3,4,5,6,7,0}; what would be the output of printf('%d',a[4]); ?
37. What will happen when the following code is executed? { int num; num =0; do {-- num; printf('%d\n', num); num++; } while (num >=0); }
38. Which is/are the correct signature/s of main with command line arguments?
39. What would be printed on the standard output as a result of the following code snippet? int Recur(int num) { if(num==1 || num==0) return 1; if(num%2==0) return Recur(num/2)+2; else return Recur(num-1)+3; } int main() { int a=9; printf('%d\n', Recur(a)); return 0; }
40. An array is defined with the following statement in a file, file1.c int a[ ] = { 1, 2, 3, 4, 5, 6 }; In another file, file2.c, the following code snippet is written to use the array a: extern int a[]; int size = sizeof(a); What is wrong with the above code snippet?
41. Which statements are correct for the keyword register?
42. Which one is not a type of operator ?
43. What would be printed on the standard output as a result of the following code snippet? char i = 'A'; char *j; j = & i; *j = *j + 32; printf('%c',i);
44. Which standard function is used to deallocate memory allocated by the malloc() function?
45. What will be printed on the standard output as a result of the following code snippet? void main() { char arr[] = {'R','A','M'}; printf('%d',strlen(arr)); }
46. What will be printed on the standard output as a result of the following code snippet? void main() { char arr[] = {'R','A','M','\0'}; printf('%d',strlen(arr)); }
47. Which comparison statement will be true if an integer is 16 bits and a long is 32 bits on a machine?
48. Which statements will result in a compilation error?
49. Is the following statement correct? If not, why not? If yes, what is the size of the array? int array[][3] = { {1,2}, {2,3}, {3,4,2} };
50. If a two dimensional array arr[4][10](an array with 4 rows and 10 columns) is to be passed in a function, which of the following would be the valid parameters in the function definition?
51. What would be printed on the standard output as a result of the following code snippet? #define max(a, b) ((a) > (b)?(a):(b)) main() { int a=4; float b=4.5; printf('%.2f\n',max(a, b)); }
52. What would be printed on the standard output as a result of the following code snippet? main() { void addup (int b); addup(b); return 0; } int b = 5; void addup (int b) { static int v1; v1 = v1+b; printf('%d ', v1); }
53. What would be printed on the standard output as a result of the following code snippet? #include main() { unsigned char a=255; a = a+1; printf('%d',a); return 0; }
54. Given the array: int num[3][4]= { {3,6,9,12}, {15,25,30,35}, {66,77,88,99} }; what would be the output of *(*(num+1)+1)+1?
55. Identify the incorrect statement.
56. What would be the output of the following code snippet? int b = 5; main() { void addup (int b); int i; for(i=1; i<=5; i++) addup(1); return 0; } void addup (int b) { static int v1; v1 = v1+b; printf('%d ', v1); }
57. What is the return type of the following function declaration? func(char c);
58. What would be printed on the standard output as a result of the following code snippet? main( ) { char *str[ ] = { 'Manish' 'Kumar' 'Choudhary' }; printf ( '\nstring1 = %s', str[0] ); printf ( '\nstring2 = %s', str[1] ); printf ( '\nstring3 = %s', str[2] ); }
59. What is the return value in case a file is not opened successfully by using fopen()?
60. Which function will convert a string into an integer?
61. Which one is not a string function?
62. Which function returns the current pointer position within a file?
63. What will happen if you assign a value to an element of an array the subscript of which exceeds the size of the array?
64. What would be printed on the standard output as a result of the following code snippet? main() { int arr[10]; int a = sizeof(arr); printf('%d\n',a); return 0; }
65. Which function will you use to position the file pointer at the beginning of the file?
66. Given the following array: char books[][40]={ 'The Little World of Don Camillo', 'To Kill a Mockingbird', 'My Family and Other Animals', 'Birds, Beasts and Relatives' }; what would be the output of printf('%c',books[2][5]);?
67. Suppose there is a file a.dat which has to be opened in the read mode using the FILE pointer ptr1, what will be the correct syntax?
68. Which is/are the type/s of memory allocation that needs/need the programmer to take care of memory management?
69. What would be printed on the standard output as a result of the following code snippet? main() { char *s='Hello World'; char s1[20], s2[20]; int len = sscanf(s,'%s',s1); printf('%s : %d', s1, len); }
70. Which sets of conversion statements may result in the loss of data?
71. In order to read structures/records from a file, which function will you use?
72. Read the statement below: extern int a; Which statement/s pertaining to the above statement is/are correct?
73. Which one is the correct way of initializing a two-dimensional array?
74. What will be printed on the standard output as a result of the following code snippet? void main() { int i,j,k; i=4; j=30; k=0; k=j++/i++; ++k; printf('%d %d %d',i,j,k); }
75. The declaration int *(*p)[10] indicates:
76. What will be the output of the following program, assuming that data type short takes 2 bytes for storage? struct node { unsigned char bit1 : 1; unsigned char bit2 : 1; unsigned short bit3 : 7; } node1; main() { int size = sizeof(node1); printf('%d', size); }