0% found this document useful (0 votes)
109 views9 pages

C Programming MCQ Final

The document contains 30 multiple choice questions related to C programming concepts such as data types, arrays, functions, pointers, files etc. It tests fundamental knowledge of C syntax, keywords, operators and standard library functions. The questions cover a wide range of basic and intermediate C programming topics to assess overall understanding of the C language.

Uploaded by

Praphul Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views9 pages

C Programming MCQ Final

The document contains 30 multiple choice questions related to C programming concepts such as data types, arrays, functions, pointers, files etc. It tests fundamental knowledge of C syntax, keywords, operators and standard library functions. The questions cover a wide range of basic and intermediate C programming topics to assess overall understanding of the C language.

Uploaded by

Praphul Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

1.Which of the following isn’t C compiler?

(a)MinGw (b)AOCC
(c) LabWindows (d)Gambas

Ans: d

2. Which of the following syntax is incorrect ?


(a) Double salary; (b) float a,b;
(c)goto label; (d)int age[10];

Ans: a

3. Which of the following is incorrect?


(a) int num1; (b) float your salary;
(C) char students_name[30]; (d) int age;

ans: b

4. Which one is wrong syntax ?


(a) const int SIDE = 15; (b) int const SIDE = 15;
(c) #define PI 3.1415 (d) #define PI= 3.1415

ans d

5. Which of the following isn’t user defined data type?


(a)enumeration (b)array
(c)union (c) structure
ans: b

6.#include”file” is used for including


(a) system header files (b) user defined header files
(c)anything else (d) numeric constant

ans: b

7. The output of the following program is


main() {
int num = 10;
char c = '$';
float sum;
sum = num + c;
printf("sum = %f\n", sum );}
(a)46 (b) 36
(c)48 (d)36

ans: a

8. Conditinal operator is
(a) binary operator (b) unary operator
(c) ternary operator (d) none of the above

ans: c
9. Which of the following prototype declarations is valid ? [d]
(a) int (fun) void;
(b) double fun;
(c) float fun (x, y, n);
(d) void fun (int,int);

10. A function which calls itself is called a ___ function. [c]


A) Self Function
B) Auto Function
C) Recursive Function
D) Static Function
11. What is the output of this C code? [d]

int main()
{
int a = 0, i = 0, b;
for (i = 0;i < 5; i++)
{
a++;
continue;
}
}
(a) 2
(b) 3
(c) 4
(d) 5

12. int i = 4; [a]


switch (i)
{
default: ;
case 3:
i += 5;
if ( i == 8)
{
i++;
if (i == 9) break;
i *= 2;
}
i -= 4;
break;
case 8:
i += 5;
break;
}
printf("i = %d\n", i);
What will the output of the sample code above be?
a) i = 5
b) i = 8
c) i = 9
d) i = 10

13. What will be the output of the following program ? [a]


#include
void main()
{ int a = 2;
switch(a)
{ case 1:
printf("goodbye"); break;
case 2:
continue;
case 3:
printf("bye");
}
}
a) error
b) goodbye
c) bye
d) byegoodbye

14. The Default Parameter Passing Mechanism is called as [a]


A. Call by Value
B. Call by Reference
C. Call by Address
D. Call by Name

15. What is function? [d]


A. Function is a block of statements that perform some specific task.
B. Function is the fundamental modular unit. A function is usually designed to perform a specific
task.
C. Function is a block of code that performs a specific task. It has a name and it is reusable
D. All the above

16. What is the work of break keyword? [c]


A. Halt execution of program
B. Restart execution of program
C. Exit from loop or switch statement
D. None of the above

17. Which of the following prototype declarations is valid ? [d]


(a) int (fun) void;
(b) double fun;
(c) float fun (x, y, n);
(d) void fun (int,int);

18. We want to declare a two-dimensional integer type array called matrix for 3 rows and 5
columns. Which of the following declarations are correct? [d]
(a) int matrix [3],[5];
(b) int matrix [5] [3];
(c) int matrix [3,5];
(d) int matrix [3] [5];

19. What is the output of the following program? [c]


main ( )
{
int m [ ] = { 1,2,3,4,5 }
int x, y = 0;
for (x = 0; x < 5; x++ )
{
y = y + m [ x ];
}
printf(“%d”, y) ;
}
a) 0
b) 5
c) 15
d) 1
20. Elements in an array are accessed _____________ [b]
a) randomly
b) sequentially
c) exponentially
d) logarithmically

21. If str[30] is a string variable, which one is correct way to read the string? [c]
a) scanf(“%c”,&str);
b) scanf(“%s”,&str);
c) scanf(“%s”,str);
d) scanf(“%c”,str)

22. Which one is correct way of declaring 2D array? [d]


a) a[ ][ ];
b) a[ ][ ]={2,4,5,3,8,1,7,8};
c) a[3][4]={2,4,6,8,9,7,5,3,1};
d) a[3][4];

23. What is the output of C program below? [c]


int a[5]={3,5,1,6,8};
printf(“ %d”,a[3]);
a) 1
b) 3
c) 6
d) 3,5,1,6,8

24. What will be the output of following program? [c]

int main()
{
char str[]="JACKIE CHAN";
int i=0;
while(str[i] != 0)
{
printf("%c",str[i]);
i++;
}
return 0;
}

a) Compiler error
b) JJJJJJ JJJJ
c) JACKIE CHAN
d) None of the above

25. What will be the output of following program? [c]

int main()
{
structure campus
{
int items;
char name[10];
}a;
strcpy(a.name, "Pulchowk");
a.items=10;
printf("%s", a.name);
return 0;
}

a) Pulchowk
b) Empty string
c) Compiler error
d) None

26. What is the keyword used to declare a C file pointer.?


a.) file
b.) FILE
c.) FILEFP
d.) filefp
answer b

27. What are the C functions used to read or write a file in Text Mode.?
A) fprintf(), fscanf()
B) fread(), fwrite()
C) fprint(), fscan()
D) read(), write()

answer a
28. Syntax of malloc:
a. castType* ptr = (castType*) malloc(size)
b. castType* ptr = (castType*) malloc(n, size)
c. both a and b
d. None

29. Pointer to a variable has following


a. Value of the pointed variable
b. address of the pointed variable
c. size of the pointed variable
d. All of the above

30. int a = 123456 of size 4 bytes. If a is stored in text file, what space does it occupy?
a. 4 bytes
b. 6 bytes
c. 5 bytes
d. 2 bytes

You might also like