Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

JAWAHARLAL INSTITUTE OF TECHNOLOGY,BORAWAN

COMPUTER SCIENCE AND ENGINEERING DEPAETMENT

C Language Questions

1. What will be the output of the following code?


#include <stdio.h>
int main() {
int a = 3, b = 5;
int t = a;
a = b;
b = t;
printf("%d %d", a, b);
return 0;
}
1. 3 5
2. 3 3
3. 5 5
4. 5 3 *

2. What is the output of the following code?


int main() {
int sum = 2 + 4 / 2 + 6 * 2;
printf("%d", sum);
return 0;
}

1. 2
2. 15
3. 16 *
4. 18

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


#include <stdio.h>
void solve() {
int a = 3;
int res = a++ + ++a + a++ + ++a;
printf("%d", res);
}
int main() {
solve();
return 0;
}
1. 12
2. 24
3. 20*
4. 18

4. Which of the following is an exit controlled loop?

1. While loop.
2. For loop.
3. do-while loop.
4. None of the above.

5. Which is correct with respect to the size of the data types in C?

1. char > int > float


2. char < int < float
3. int < char < float
4. int < chat > float

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

#include <stdio.h>

int main()
{
int x = 20;
x %= 3;
printf("%d",x);

return 0;
}

1. 2*
2. 2.5
3. Error
4. Warning

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


#include <stdio.h>

int main()
{
float x = 23.456;
printf("%.2f",x);
return 0;
}

1. 23.45600
2. 23.456
3. 23.45
4. 23.46 *

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


#include <stdio.h>

void main()
{
int x = 10;
int y = x++ + 20;

printf("%d,%d",x,y);

return 0;
}

1. 11,30 *
2. 11,31
3. 10,30
4. 10,31

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

#include <stdio.h>

int main()
{
unsigned char c=290;
printf("%d",c);
return 0;
}

1. 290
2. 256
3. 34 *
4. Garbage

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

#include <stdio.h>
int main()
{
int a=0;

a=5||2|1;
printf("%d",a);

return 0;
}

1. 1
2. 7
3. 0
4. 8

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

#include <stdio.h>
int main()
{
printf((43 > 43) ? "value 1 is greater!" : "value 1 is not greater!");
return 0;
}

1. value 1 is not greater *


2. value 1 is greater
3. Error
4. None of these

12. Which of these if...else block syntax is correct?


1. if(condition){
}
else {
}*
2. if(condition){
}
else(condition){
}
3. if{
}
else {
}
4. None of these

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

#include <stdio.h>

int main()
{
int marks = 43;

if (marks > 90)


printf("Grade : A ");
else if (marks > 75)
printf("Grade : B ");
else if (marks > 60)
printf("Grade : C ");
if (marks > 40)
printf("Grade : D ");
else
printf("Fail ");
return 0;
}

1. Grade : A
2. Grade : B
3. Grade : C
4. Grade : D *

14. Without a break statement in switch what will happen?

1. All cases will work properly


2. Cases will fall through after matching the first check *
3. Switch will throw error
4. All of these
15. What will be the output of the following C code?

#include <stdio.h>

int main(){
char grade = 'B';

switch (grade) {
case 'A':
printf("Excellent!\n");
case 'B':
case 'C':
printf("Well done\n");
case 'D':
printf("You passed\n");
case 'F':
printf("Better try again\n");
break;
default:
printf("Invalid grade\n");
}
}

1. Well done
2. You passed
3. Better try again
4. All of these *

16. Which statements are used to change the execution sequence?

1. Loop control statement


2. Function statement
3. Conditional statement
4. All of these

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


#include <stdio.h>

int main(){
int a = 11;

while (a < 20) {


printf("%d ", a);
a += 2;
}

return 0;
}

1. 11 13 15 17 19 *
2. 11 12 13 14 15 16 17 18 19 20
3. 11 13 15 17 19 21
4. None of these

18. In which year was C language developed?

1. 1962
2. 1978
3. 1979
4. 1972

19. C is a ___.

A. Low level language


B. High level language
C. Medium level language
D. None of the above

20. What is the extension of a C language header file?

A. .c
B. .cpp
C. .c99
D. .h

You might also like