Multiple choice questions and answers with explanation on C language. The questions are based on the basic concepts of C language like keywords, Expressions etc.
1) What will be the output of following program ?
#include<stdio.h>
int main( )
{
int i=2,j=3,k,l;
float a,b;
k = i/j * j;
l = j/i * j;
a = i/j * j;
b = j/i * i;
printf("%d %d%f%f\n",k,l,a,b);
return 0;
}
#incllude<stdio.h>
int main( )
{
int a,b;
a = -3 - - 25;
b = -3 - - (-3);
printf("a=%d b=%d\n",a,b);
return 0;
}
#include<stdio.h>
int main( )
{
float a=5,b=2;
int c,d;
c =a%d;
d =a/2;
printf("%d\n",d);
return 0;
}
#include<stdio.h>
int main( )
{
printf("nn /n/n nn/n");
return 0;
}
#include<stdio.h>
int main( )
{
int a,b;
printf("Enter two values of a and b");
scanf("%d%d",&a,&b);
printf("a=%d b=%d"a,b);
return 0;
}
1) What will be the output of following program ?
#include<stdio.h>
int main( )
{
int i=2,j=3,k,l;
float a,b;
k = i/j * j;
l = j/i * j;
a = i/j * j;
b = j/i * i;
printf("%d %d%f%f\n",k,l,a,b);
return 0;
}
- 3, 0, 0, 0
- 0, 3, 0.000000, 2.000000
- 0,0,0,0
- Error
Show/Hide Answer
Answer = B
Explanation: As K and L are integer variables so it prints the integer value as result and a and b are float variable, so float value will be print as result.
2) What will be the output of following program ?Explanation: As K and L are integer variables so it prints the integer value as result and a and b are float variable, so float value will be print as result.
#incllude<stdio.h>
int main( )
{
int a,b;
a = -3 - - 25;
b = -3 - - (-3);
printf("a=%d b=%d\n",a,b);
return 0;
}
- a = 22 b = -6
- a = -6 b = 22
- a = 3 b = 3
- No Output
Show/Hide Answer
Answer = A
Explanation:No Explanation
3) What will be the output of following program ?Explanation:No Explanation
#include<stdio.h>
int main( )
{
float a=5,b=2;
int c,d;
c =a%d;
d =a/2;
printf("%d\n",d);
return 0;
}
- 3
- 2
- Error
- None of above
Show/Hide Answer
Answer = C
Explanation: Program will give the error : Illegal use of floating point. The statement c = a%b will give the error.
4) What will be the output of program ?Explanation: Program will give the error : Illegal use of floating point. The statement c = a%b will give the error.
#include<stdio.h>
int main( )
{
printf("nn /n/n nn/n");
return 0;
}
- Nothing
- nn /n/n nn
- nn /n/n
- Error
Show/Hide Answer
Answer = B
Explanation: No Explanation
5) What will be the output of program ?Explanation: No Explanation
#include<stdio.h>
int main( )
{
int a,b;
printf("Enter two values of a and b");
scanf("%d%d",&a,&b);
printf("a=%d b=%d"a,b);
return 0;
}
- a = 0 b = 0
- a = 1 b = 1
- Values you entered
- None of above
Show/Hide Answer
Answer = C
Explanation: No Explanation
6) A character variable can at a time store ? Explanation: No Explanation
- 1 character
- 8 character
- 254 character
- None of above
Show/Hide Answer
Answer = A
Explanation: No Explanation
7) The maximum value that an integer constant can have is ? Explanation: No Explanation
- -32767
- 32767
- 1.7014e + 38
- -1.7014e + 38
Show/Hide Answer
Answer = B
Explanation: The range of an integer number is -32767 - 32767
8) Which of the following is false in C ? Explanation: The range of an integer number is -32767 - 32767
- Keywords cannot be used as variable names
- Variable names can contain a digit
- Variable names do not contain a blank space
- Capital letters can be used in variable names
Show/Hide Answer
Answer = A
Explanation: Keywords can be used as variable names but by doing this it creates confusion
9) On which if the following operator can % operator NOT be used ? Explanation: Keywords can be used as variable names but by doing this it creates confusion
- int variable
- float variable
- int constant
- All of above
Show/Hide Answer
Answer = B
Explanation: No Explanation
10) A C variable cannot start with ? Explanation: No Explanation
- An alphabet
- A number
- A special symbol other that underscore
- Both B and C
Show/Hide Answer
Answer = D
Explanation: No Explanation
Explanation: No Explanation
Do You Like This? Please take 5 seconds to share with your firends.
1 comments:
Questions are very simple...you should increase the level of difficulty then it will be more helpful to students.
Post a Comment