⫷ 10 + Questions ⫸ |What will be the output of the following c code ? Easy Explanation
What will be the output of the following c code?
Give below are the questions that you have to predict the output of the following C code , the answers to the questions are given below with explanation.
Q1. Guess the Output of the Following C code ?
int i=0;
int k=0;
for( ; i<10; i++)
{
printf(“%d “,k);
}
|
Option 1) . 0 1 2 3 4 5 6 7 8 9
Option 2) . 0 2 4 6 8 10 12 14 16
Option 3) . 0 0 0 0 0 0 0 0 0 0
Option 4) . 9 8 7 6 5 4 3 2 1 0
Q2 . Which of the following is not present in C ?
Option 1) . String
Option 2) . char
Option 3) . int
Option 4) . bool
Q3 . What will be the output of the following C code ?
int i=0;
i ++;
++ i;
printf(“%d”, i);
|
Option 1) . 0
Option 2) . 1
Option 3) . 2
Option 4) . 3
Q4. Guess the output of the following C code?
int a = 50 , b =60 ,c;
c = (a>20 && b <100);
printf(“%d “,c);
|
Option 1) . 0
Option 2) . 1
Option 3) . 01
Option 4) . 60
Q5. Every operator in C has same associativity ?
Option 1). True
Option 2). False
Q6. What will be the output of the following C code ?
int i = 30;
int m = (m > 40) ? ((m < 35)? 4:2) : ((m > 25) ? 2: 4) ;
|
Option 1) . 2
Option 2) . 4
Option 3) . 3
Option 4) . 1
Q7. Guess the output of the following C code?
int a=10;
if(a = 15)
{
printf(“%d” , a);
}
else
{
a = 16;
printf(“%d” , a);
}
|
Option 1) . 10
Option 2) . 15
Option 3) . 16
Option 4) . 15 16
Q8. Which Header file is not present in C?
Option 1) . stdio.h
Option 2) . string.h
Option 3) . bits/stdc+.h
Option 4) . stdlib.h
Q9. Which of the following access modifier is/are present in C?
Option 1) . Private
Option 2) . Protected
Option 3) . Public
Option 4) . None of the Above.
Q10. What will be the output of the following C code ?
int x=10 , y=20;
x = x+y;
y = x-y;
x = x-y;
|
Option 1) . -10 -10
Option 2) . 10 20
Option 3) . 20 10
Option 4) . 30 0
Bookmark Us to get more C questions .
Answers :
1). Option 3) . 0 0 0 0 0 0 0 0 0 0 . Since we are printing k , it is not incrementing
2). Option 1) . String . String is not present in C.
3). Option 3) . 2 . Pre-Increment and Post-Increment , Both are applied 1 time.
4). Option 2) . 1 . Both the conditions are true.
5). Option 2). False .Since , (+,-) have same but +, * have different associativity.
6). Option 1) . 2 .Ternary Operator
7). Option 2) . 15 .15 has been assigned to a.
8). Option 3) . bits/stdc+.h .It is a header file of C++.
9). Option 4) . None of the Above. OOPs Concept
10).Option 3) . 20 10 . It’s a swapping function.