1. 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); }
Answer
Correct Answer:
2
Note: This Question is unanswered, help us to find answer for this one
2. The declaration int *(*p)[10] indicates:
Answer
Correct Answer:
p is a pointer to an array of integer pointers
Note: This Question is unanswered, help us to find answer for this one
3. 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); }
Answer
Correct Answer:
5 31 8
Note: This Question is unanswered, help us to find answer for this one
4. Which of the following is the correct way of initializing a two-dimensional array?
Answer
Correct Answer:
a, b and c
Note: This Question is unanswered, help us to find answer for this one
5. In order to read structures/records from a file, which function will you use?
Answer
Correct Answer:
fread()
Note: This Question is unanswered, help us to find answer for this one
6. Which of the following sets of conversion statements may result in the loss of data?
Answer
Correct Answer:
int i; char c; c=i; i=c;
Note: This Question is unanswered, help us to find answer for this one
7. 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); }
Answer
Correct Answer:
Hello : 1
Note: This Question is unanswered, help us to find answer for this one
8. Which is/are the type/s of memory allocation that needs/need the programmer to take care of memory management?
Answer
Correct Answer:
Dynamic memory allocation
Note: This Question is unanswered, help us to find answer for this one
9. 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?
Answer
Correct Answer:
ptr1 = fopen("a.dat","r");
Note: This Question is unanswered, help us to find answer for this one
10. 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]);?
Answer
Correct Answer:
m
Note: This Question is unanswered, help us to find answer for this one
11. Which function will you use to position the file pointer at the beginning of the file?
Answer
Correct Answer:
a or b
Note: This Question is unanswered, help us to find answer for this one
12. 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; }
Answer
Correct Answer:
40
Note: This Question is unanswered, help us to find answer for this one
13. What will happen if you assign a value to an element of an array the subscript of which exceeds the size of the array?
Answer
Correct Answer:
You will get an error message from the compiler
Note: This Question is unanswered, help us to find answer for this one
14. Which function returns the current pointer position within a file?
Answer
Correct Answer:
ftell()
Note: This Question is unanswered, help us to find answer for this one
15. Which of the following is not a string function?
Answer
Correct Answer:
strcomp()
Note: This Question is unanswered, help us to find answer for this one
16. Which function will convert a string into an integer?
Answer
Correct Answer:
atoi()
Note: This Question is unanswered, help us to find answer for this one
17. What is the return value in case a file is not opened successfully by using fopen()?
Answer
Correct Answer:
NULL
Note: This Question is unanswered, help us to find answer for this one
18. 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] ); }
Note: This Question is unanswered, help us to find answer for this one
19. What is the return type of the following function declaration? func(char c);
Answer
Correct Answer:
void
Note: This Question is unanswered, help us to find answer for this one
20. 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); }
Answer
Correct Answer:
1 2 3 4 5
Note: This Question is unanswered, help us to find answer for this one
21. Identify the incorrect statement.
Answer
Correct Answer:
Memory is reserved when a structure label is defined
Note: This Question is unanswered, help us to find answer for this one
22. 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?
Answer
Correct Answer:
26
Note: This Question is unanswered, help us to find answer for this one
23. 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; }
Answer
Correct Answer:
0
Note: This Question is unanswered, help us to find answer for this one
24. 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); }
Answer
Correct Answer:
Will result in Compilation Error
Note: This Question is unanswered, help us to find answer for this one
25. 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)); }
Answer
Correct Answer:
4.50
Note: This Question is unanswered, help us to find answer for this one
26. 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?
Answer
Correct Answer:
fn(int arr[4][10])
Note: This Question is unanswered, help us to find answer for this one
27. 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} };
Answer
Correct Answer:
Yes, the size is three columns by three rows
Note: This Question is unanswered, help us to find answer for this one
28. Which of the following statements will result in a compilation error?
Answer
Correct Answer:
int n=5, x; x= ++n++;
Note: This Question is unanswered, help us to find answer for this one
29. Which of the following comparison statements will be true if an integer is 16 bits and a long is 32 bits on a machine?
Answer
Correct Answer:
-1L < 1U
Note: This Question is unanswered, help us to find answer for this one
30. 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)); }
Answer
Correct Answer:
3
Note: This Question is unanswered, help us to find answer for this one
31. 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)); }
Answer
Correct Answer:
Cannot be determined
Note: This Question is unanswered, help us to find answer for this one
32. Which standard function is used to deallocate memory allocated by the malloc() function?
Answer
Correct Answer:
free
Note: This Question is unanswered, help us to find answer for this one
33. 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);
Answer
Correct Answer:
a
Note: This Question is unanswered, help us to find answer for this one
34. Which of the following is not a type of operator ?
Answer
Correct Answer:
Rational
Note: This Question is unanswered, help us to find answer for this one
35. 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?
Answer
Correct Answer:
An extern array of unspecified size is an incomplete type. The size of the operator during compile time is unable to learn the size of an array that is defined in another file
Note: This Question is unanswered, help us to find answer for this one
36. 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; }
Answer
Correct Answer:
10
Note: This Question is unanswered, help us to find answer for this one
37. Which of the following is/are the correct signature/s of main with command line arguments?
Answer
Correct Answer:
int main(int argc, char **argv)
Note: This Question is unanswered, help us to find answer for this one
38. 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]); ?
Answer
Correct Answer:
5
Note: This Question is unanswered, help us to find answer for this one
39. 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)); }
Answer
Correct Answer:
5
Note: This Question is unanswered, help us to find answer for this one
40. 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)); }
Answer
Correct Answer:
9,10
Note: This Question is unanswered, help us to find answer for this one
41. 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; }
Answer
Correct Answer:
Compilation Error in "Line 2"
Note: This Question is unanswered, help us to find answer for this one
42. 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); }
Answer
Correct Answer:
6 5 7
Note: This Question is unanswered, help us to find answer for this one
43. 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; }
Answer
Correct Answer:
sdfgh
Note: This Question is unanswered, help us to find answer for this one
44. Which function allocates memory and initializes elements to 0?
Answer
Correct Answer:
calloc()
Note: This Question is unanswered, help us to find answer for this one
45. Which of the following standard functions is used to close a file?
Answer
Correct Answer:
fclose()
Note: This Question is unanswered, help us to find answer for this one
46. Select the correct statement about arrays.
Answer
Correct Answer:
An array declared as A[100][100] can hold a maximum of 10000 elements
Note: This Question is unanswered, help us to find answer for this one
47. 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(); }
Answer
Correct Answer:
2 2 3 2 4 2
Note: This Question is unanswered, help us to find answer for this one
48. What does the following function do? int fn(unsigned int x) { int count = 0; for(; x!=0; x&=(x-1)) count++; return count; }
Answer
Correct Answer:
Returns the number of 1 bits(bits having one) in the number x
Note: This Question is unanswered, help us to find answer for this one
49. Which of the following functions is used to extract formatted input from a file?
Answer
Correct Answer:
fscanf()
Note: This Question is unanswered, help us to find answer for this one
50. 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;
Answer
Correct Answer:
2,3
Note: This Question is unanswered, help us to find answer for this one
51. What is wrong with the following function prototype statement? int func();
Answer
Correct Answer:
There is nothing wrong with the statement
Note: This Question is unanswered, help us to find answer for this one
52. Which of the following is not a storage type?
Answer
Correct Answer:
global
Note: This Question is unanswered, help us to find answer for this one
53. 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]); }
Answer
Correct Answer:
6
Note: This Question is unanswered, help us to find answer for this one
54. 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; }
Answer
Correct Answer:
Result in compilation error
Note: This Question is unanswered, help us to find answer for this one
55. Which of the following statements is valid and correct?
Note: This Question is unanswered, help us to find answer for this one
56. The declaration int (*p[5])() means:
Answer
Correct Answer:
p is an array of pointers to functions the return type of which is an integer
Note: This Question is unanswered, help us to find answer for this one
57. 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; }
Answer
Correct Answer:
0 1 0 1
Note: This Question is unanswered, help us to find answer for this one
58. What is the function to concatenate two strings?
Answer
Correct Answer:
strcat()
Note: This Question is unanswered, help us to find answer for this one
59. Which of the following is not a valid mode for opening a file?
Answer
Correct Answer:
i
Note: This Question is unanswered, help us to find answer for this one
60. Which function will convert a string into a double precision quantity?
Answer
Correct Answer:
atof()
Note: This Question is unanswered, help us to find answer for this one
61. 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; }
Answer
Correct Answer:
5 7 8
Note: This Question is unanswered, help us to find answer for this one
62. 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; }
Answer
Correct Answer:
Assertion 'n > 7' failed; Program aborts at statement 2
Note: This Question is unanswered, help us to find answer for this one
63. Which of the following file modes would mean read + append?
Answer
Correct Answer:
a+
Note: This Question is unanswered, help us to find answer for this one
64. 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)); }
Answer
Correct Answer:
5
Note: This Question is unanswered, help us to find answer for this one
65. Which of the following is the correct way of initializing a two-dimensional array?
Answer
Correct Answer:
a, b and c
Note: This Question is unanswered, help us to find answer for this one
66. Which header file are methods(or macros) isalpha(), islower() a part of?
Answer
Correct Answer:
ctype.h
Note: This Question is unanswered, help us to find answer for this one
67. 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; }
Answer
Correct Answer:
2
Note: This Question is unanswered, help us to find answer for this one
68. 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?
Answer
Correct Answer:
For statement 1, the header file will be searched in the standard system directories such as
Note: This Question is unanswered, help us to find answer for this one
69. What does the argv[0] represent?
Answer
Correct Answer:
The program name
Note: This Question is unanswered, help us to find answer for this one
70. 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);
Answer
Correct Answer:
The code snippet will throw a compilation error
Note: This Question is unanswered, help us to find answer for this one
71. 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; }
Answer
Correct Answer:
7 7.00 7.000000
Note: This question has more than 1 correct answers
Note: This Question is unanswered, help us to find answer for this one
72. Which function will you use to write a formatted output to the file?
Answer
Correct Answer:
fprintf()
Note: This Question is unanswered, help us to find answer for this one
73. By which file function you can position the file pointer in accordance with the current position?
Answer
Correct Answer:
fseek()
Note: This Question is unanswered, help us to find answer for this one