0% found this document useful (0 votes)
132 views

C Programming Question

This document contains 25 multiple choice questions about C programming. The questions cover topics like C preprocessor directives, data types, operators, functions, control structures, arrays, structures and more. Example code snippets are provided for many questions to test understanding of C syntax and program execution. The goal appears to be to assess a tester's knowledge of core C programming concepts and problem solving abilities.

Uploaded by

mkpooja1622
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)
132 views

C Programming Question

This document contains 25 multiple choice questions about C programming. The questions cover topics like C preprocessor directives, data types, operators, functions, control structures, arrays, structures and more. Example code snippets are provided for many questions to test understanding of C syntax and program execution. The goal appears to be to assess a tester's knowledge of core C programming concepts and problem solving abilities.

Uploaded by

mkpooja1622
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/ 12

C PROGRAMMING QUESTIONS

1. The C-preprocessors are specified with _________ symbol.


a) #
b) $
c) ” ”
d) &

2. What is the sizeof(char) in a 32-bit C compiler?


a) 1 bit
b) 2 bits
c) 1 Byte
d) 2 Bytes

3. What will be the output of the following C code?


#include <stdio.h>
int main()
{
int y = 10000;
int y = 34;
printf("Hello World! %d\n", y);
return 0;
}
a) Compile time error
b) Hello World! 34
c) Hello World! 1000
d) Hello World! followed by a junk value
4. What will be the output of the following C code? (Initial values:
x= 7, y = 8)
#include <stdio.h>
void main()
{
float x;
int y;
printf("enter two numbers \n");
scanf("%f %f", &x, &y);
printf("%f, %d", x, y);
}

a) 7.000000, 7
b) Run time error
c) 7.000000
d) Varies

5. What is the difference between the following 2 C codes?


Program 1
#include <stdio.h>
int main()
{
int d, a = 1, b = 2;
d = a++ + ++b;
printf("%d %d %d", d, a, b);
}
Program 2
#include <stdio.h>
int main()
{
int d, a = 1, b = 2;
d = a++ +++b;
printf("%d %d %d", d, a, b);
}
a) No difference as space doesn’t make any difference, values of a, b, d
are same in both the case
b) Space does make a difference, values of a, b, d are different
c) Program 1 has syntax error, program 2 is not
d) Program 2 has syntax error, program 1 is not

6. What will be the output of the following C code?


#include <stdio.h>
int main()
{
int i = 0;
do
{
i++;
if (i == 2)
continue;
printf("In while loop ");
} while (i < 2);
printf("%d\n", i);
}

a) In while loop 2
b) In while loop in while loop 3
c) In while loop 3
d) Infinite loop

7. What is the output of this C code?

#include <stdio.h>
int main()
{
float f = 0.1;
if (f == 0.1)
printf("True");
else
printf("False");
}
a) True
b) False

8. What is the output of this C code?


#include <stdio.h>
main()
{
int n = 0, m = 0;
if (n > 0)
if (m > 0)
printf("True");
else
printf("False");
}
a) True
b) False
c) No Output will be printed
d) Run Time Error

9. What will be the output of the following C code?


#include <stdio.h>
void main()
{
int x = 5.3 % 2;
printf("Value of x is %d", x);
}
a) Value of x is 2.3
b) Value of x is 1
c) Value of x is 0.3
d) Compile time error

10. Where in C the order of precedence of operators do not exist?


a) Within conditional statements, if, else
b) Within while, do-while
c) Within a macro definition
d) None of the mentioned

11. What will be the output of the following C function?


#include <stdio.h>
void reverse(int i);
int main()
{
reverse(1);
}
void reverse(int i)
{
if (i > 5)
return ;
printf("%d ", i);
return reverse((i++, i));
}

a) 1 2 3 4 5
b) Segmentation fault
c) Compilation error
d) Undefined behaviour

12. Which of these won’t return any value?


a. void
b. null
c. free
d. empty

13. The global variables are ____________.


a. External
b. Internal
c. Both External and Internal
d. None of the above
14. Which of these is NOT a relational or logical operator?

a. =
b. ||
c. ==
d. !=

15. Determine the output of the C code mentioned below:

#include <stdio.h>
int main()
{
float q = ‘a’;
printf(“%f”, q);
return 0;
}
a. run time error
b. a
c. 97.000000
d. a.0000000

16. What is the output of the following code snippet?


#include <stdio.h>
int main() {
int a[] = {1, 2, 3, 4};
int sum = 0;
for(int i = 0; i < 4; i++) {
sum += a[i];
}
printf("%d", sum);
return 0;
}

a.1
b.4
c.20
d.10

17. What is the output of the following code snippet?

int main() {
int sum = 2 + 4 / 2 + 6 * 2;
printf("%d", sum);
return 0;
}
a. 2
b. 15
c. 16
d. 18

18. In which of the following languages is function overloading


not possible?

a. c
b. c++
c. java
d. python

19. What will be the output of the following code snippet?

#include <stdio.h>
void solve() {
int ch = 2;
switch(ch) {
case 1: printf("1 ");
case 2: printf("2 ");
case 3: printf("3 ");
default: printf("None");
}
}
int main() {
solve();
return 0;
}

a. 1 2 3 none
b. 2
c. 2 3 none
d. none

20. Which of the following is not true about structs in C?

a.no data hiding


b. functions are allowed inside structs
c .constructors are not allowed structs
d. cannot have static members in the struct body

21. write a program to find factorial:


22. write a program to find a odd or even:
23. write a program for fibnoci series :
24. write a program for armstrong number:
25. write program for swapping 2 numbers which is a=10, b= 20:

You might also like