Q 1 - What is your comment on the below C
statement? m = a[i++]; %d, %d", i, j, m);
printf("%d,
return 0;
}
signed int *p=(int*)malloc(sizeof(unsigned int));
A - Improper type casting A. 2, 1, 15
B - Would throw Runtime error B. 1, 2, 5
C - Memory will be allocated but cannot hold an int C. 3, 2, 15
value in the memory D. 2, 3, 20
D - No issue with statement Answer: C
Answer : D 5. Is there any difference int the following
Q 2 - What is the output of the following declarations?
program? int fun(int arr[]);
int fun(int arr[2]);
#include<stdio.h> A.YES
B.NO
main() Answer: B
{ 6. What is the similarity between a structure, union
and enumeration?
int x = 65, *p = &x; A. All of them let you define new values
B. All of them let you define new data types
void *q=p; C. All of them let you define new pointers
D. All of them let you define new structures
char *r=q;
Answer: B
printf("%c",*r);
7. What will be the output of the program ?
}
#include<stdio.h>
A - Garbage character. B-A int main()
{
C - 65 D - Compile error enum days {MON=-1, TUE, WED=6, THU, FRI,
Answer : B SAT};
printf("%d, %d, %d, %d, %d, %d\n", MON, TUE,
3. What will happen if in a C program you assign a WED, THU, FRI, SAT);
return 0;
value to an array element whose subscript exceeds
}
the size of array?.
A. The element will be set to 0.
B. The compiler would report an error. A.-1, 0, 1, 2, 3, 4
B. -1, 2, 6, 3, 4, 5
C. The program may crash if some important data C. -1, 0, 6, 2, 3, 4
D. -1, 0, 6, 7, 8, 9
gets overwritten.
D. The array size would appropriately grow. Answer: B
8. Point out the error in the program?
Answer: C
4. What will be the output of the program ?
struct emp
{
int ecode;
#include<stdio.h> struct emp *e;
};
int main()
{ A. Error: in structure declaration B. Linker Error
int a[5] = {5, 1, 15, 20, 25}; C. No Error D. None of above
int i, j, m; Answer: C
i = ++a[1]; 9.What is (void*)0?
j = a[1]++;
A. Representation of NULL pointer
} /* Some code */
B. Representation of void pointer
C. Error A. 1. KR Notation
2. ANSI Notation
D. Error
B. 1. Pre ANSI C Notation
Answer: A
2. KR Notation
C. 1. ANSI Notation
10. Can you combine the following two statements
into one? 2. KR Notation
D. 1. ANSI Notation
char *p; 2. Pre ANSI Notation
p = (char*) malloc(100);
Answer: C
A. char p = *malloc(100); 15. Which of the following statements are correct
B. char *p = (char) malloc(100); about the program?
C. char *p = (char*)malloc(100); #include<stdio.h>
D. char *p = (char *)(malloc*)(100);
Answer: C int main()
{
11. How many bytes are occupied by near, printf("%p\n", main());
far and huge pointers (DOS)? return 0;
A. near=2 far=4 huge=4 }
B. near=4 far=8 huge=8
C. near=2 far=4 huge=8 A. It prints garbage values infinitely
D. near=4 far=4 huge=8 B. Runs infinitely without printing anything
Answer: A C. Error: main() cannot be called inside printf()
D. No Error and print nothing
12. The library function used to find the last Answer: B
occurrence of a character in a string is
A. strnstr() 16. What is the output of this C code?
B. laststr()
C. strrchr() 1. #include <stdio.h>
D. strstr() 2. int main()
3. {
Answer: C
4. while ()
13. What will be the output of the program ? 5. printf("In while loop ");
6. printf("After loop\n");
#include<stdio.h>
#include<string.h> 7. }
A.In while loop after loop
int main() B. After loop
{ C. Compile time error
printf("%d\n", strlen("123456")); D. Infinite loop
return 0; Answer: C
}
17. The format identifier %i is also used for _____
A.6 data type?
B.12 A. char
C.7 B. int
D.2 C. float
Answer: A D. double
Answer: B
14. What is the notation for following functions?
18. Which data type is most suitable for storing a
1. int f(int a, float b) number 65000 in a 32-bit system?
{ A. signed short
/* Some code */ B. unsigned short
} C. long
D. int
2. int f(a, b) Answer: B
int a; float b;
{
19. What is the size of an int data type?
A. 4 Bytes
B. 8 Bytes
C. Depends on the system/compiler
D. Cannot be determined.
Answer: C
20. In C, if you pass an array as an argument to a
function, what actually gets passed?
A. Value of elements in array
B. First element of the array
C. Base address of the array
D. Address of the last element of array
Answer: C