C Programming Based Practice Questions for GATE Computer Science

1. Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
(a) rem = 3.14 % 2.1;
(b) rem = modf(3.14, 2.1);
(c) rem = fmod(3.14, 2.1);
(d) Remainder cannot be obtained in floating point division.

It's Solution Explanation

2. What are the types of linkages?

(a) Internal and External (b) External, Internal and None
(c) External and None (d) Internal

It's Solution Explanation

3. Which of the following special symbol allowed in a variable name?

(a) * (asterisk) (b) | (pipeline)
(c) - (hyphen) (d) _ (underscore)

It's Solution Explanation

4. Is there any difference between following declarations?

1: extern int fun();
2: int fun();

(a) Both are identical
(b) No difference, except extern int fun(); is probably in another file
(c) int fun(); is overrided with extern int fun();
(d) None of these

It's Solution Explanation

5. How would you round off a value from 1.66 to 2.0?

(a) ceil(1.66) (b) floor(1.66)
(c) roundup(1.66) (d) roundto(1.66)

It's Solution

6. By default a real number is treated as a:

(a) float (b) double
(c) long double (d) far double

It's Solution

7. Which of the following is not user defined data type?

1: struct book
char name[10];
float price;
int pages;
2: long int l = 2.35;
3: enum day {Sun, Mon, Tue, Wed};
(a) 1 (b) 2
(c) 3 (d) Both 1 and 2

It,s Solution

8. Is the following statement a declaration or definition?
extern int i;

(a) Declaration (b) Definition
(c) Function (d) Error

It's Solution

C Programming for gate cse

9. Identify which of the following are declarations:

1: extern int x;
2: float square ( float x ) { ... }
3: double pow(double, double);
(a) 1 (b) 2
(c) 1 and 3 (d) 3

It's Solution

10. In the following program where is the variable a getting defined and where it is getting declared?

int main()
extern int a;
printf("%d\n", a);
return 0;
int a=20;

(a) extern int a is declaration, int a = 20 is the definition
(b) int a = 20 is declaration, extern int a is the definition
(c) int a = 20 is definition, a is not defined
(d) a is declared, a is not defined

It's Solution

11. When we mention the prototype of a function?

(a) Defining (b) Declaring
(c) Prototyping (d) Calling

It's Solution

12. What is (void*)0?
(a) Representation of NULL pointer (b) Representation of void pointer
(c) Error (d) None of above

Answer (a)

13. Can you combine the following two statements into one?
char *p;
p = (char*) malloc(100);
(a) char p = *malloc(100); (b) char *p = (char) malloc(100);
(c) char *p = (char*)malloc(100); (d) char *p = (char *)(malloc*)(100);

Solution: Option (c)

14. In which header file is the NULL macro defined?
(a) stdio.h (b) stddef.h
(c) stdio.h and stddef.h (d) math.h

Solution: Option (c)

15. How many bytes are occupied by near, far and huge pointers (DOS)?
(a) near=2 far=4 huge=4 (b) near=4 far=8 huge=8
(c) near=2 far=4 huge=8 (d) near=4 far=4 huge=8

It's Solution

16. If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable?
(a) . (b) &
(c) * (d) ?

Solution: Option (d)

17. What would be the equivalent pointer expression for referring the array element a[i][j][k][l]?
(a) ((((a+i)+j)+k)+l) (b) *(*(*(*(a+i)+j)+k)+l)
(c) (((a+i)+j)+k+l) (d) ((a+i)+j+k+l)

Solution: Option (b)

18. A pointer is:
(a) A keyword used to create variables
(b) A variable that stores address of an instruction
(c) A variable that stores address of other variable
(d) All of the above

Solution: Option (c)

19. The operator used to get value at address stored in a pointer variable is:
(a) * (b) &
(c) && (d) ||

Solution: Option (a)

20. What is the output of the program given below?
int main()
enum status { pass, fail, atkt};
enum status stud1, stud2, stud3;

stud1 = pass;
stud2 = atkt;
stud3 = fail;
printf("%d, %d, %d\n", stud1, stud2, stud3);
return 0;
(a) 0, 1, 2 (b) 1, 2, 3
(c) 0, 2, 1 (d) 1, 3, 2

It's Solution

Keywords: c aptitude questions and answer with explanation,c language tutorial,c programming tutorial, c programming tutorial pdf, c cat exam, c and c++ questions and answers for freshers