MCQ:
1. What will be output if you compile and execute the following ‘C’ code?
void main()
{
float a=5.2;
if(a==5.2)
printf("Equal");
else
if(a<5.2)
printf("Less than");
else
printf("Greater than");
}
A) Equal
B) Less than
C) Greater than
D) Compilation error
3. What is the output of the following program segment?
4 What will be the output of the following ‘C’ program
6. find Output
int main()
Question:
1. . Grade of steel is assigned according to the following conditions:
A. Hardness must be >50
B. Carbon content must be >0.7
C. Tensile strength must be >5500
The grades are as follows:
If all the conditions are met then grade is 10.
If conditions 1 and 2 are met then grade is 9.
If conditions 2 and 3 are met then grade is 8.
If conditions 1 and 3 are met then grade is 7.
If none of the conditions are met then grade is 6.
2. What are the disadvantages of nested if-else statement?
1. What will be output if you compile and execute the following ‘C’ code?
void main()
{
float a=5.2;
if(a==5.2)
printf("Equal");
else
if(a<5.2)
printf("Less than");
else
printf("Greater than");
}
A) Equal
B) Less than
C) Greater than
D) Compilation error
2. What would be value of j after the following is executed?
k=17;
j=6;
if (k < 10)
j=8;
j=j+1;
j=j+2;
A) 8
B) 9
C) 7
D) 10
3. What is the output of the following program segment?
#include<stdio.h>
main()
{
int i=10, m=10;
clrscr();
printf(“%d”, i>m?i*i:m/m,20);
getch();
}
4 What will be the output of the following ‘C’ program
main()
{
int a=5;
float b=5.0;
if(a==b)
printf(“a and b are equal”);
else
printf(“a and b are different”);
}
A) a and b are equal
B) a and b are different
C) Error
D) None of the above
5 What will be the output of the following ‘C’ program?
main()
{
int a=1;
int b=5;
if(a=5||b>10)
printf(“I will certainly pass”);
else
printf(“I am not so sure about the result”);
}
A) I will certainly pass
B) I am not so sure about the result
C) Error
D) None of the above
6. find Output
int main()
{
chr str[]="smaller";
int a= 100;
printf(a>10?"greater":"%s",str);
return 0;
}
a greater
b smaller
c compuiler error
d 100
7. Find Output
char c = 'f';
7. Find Output
char c = 'f';
switch (c)
{
default:
printf("unknown colour ");
case 'r':
case 'R':
printf("Red ");
case 'g':
case 'G':
printf("Green ");
break;
case 'b':
case 'B':
printf("Blue");
} i
Question:
1. . Grade of steel is assigned according to the following conditions:
A. Hardness must be >50
B. Carbon content must be >0.7
C. Tensile strength must be >5500
The grades are as follows:
If all the conditions are met then grade is 10.
If conditions 1 and 2 are met then grade is 9.
If conditions 2 and 3 are met then grade is 8.
If conditions 1 and 3 are met then grade is 7.
If none of the conditions are met then grade is 6.
2. What are the disadvantages of nested if-else statement?
1 3. Write a ‘C’ program to calculate the electricity bill using if..else if, as per the following details * Given the number of units consumed, unit charges are as follows:
i) For first 50 units Rs. 0.50/unit
ii) For next 100 units Rs. 0.75/unit
iii) For next 100 units Rs. 1.20/unit
iv) For unit above 250 Rs. 1.50/unit * Add fuel surcharge 20% and Govt. Tax 10% on bill to calculate the total bill.
4. Write a C program that displays the recommended actions depending on the color of a traffic light using the if statement..
i) For first 50 units Rs. 0.50/unit
ii) For next 100 units Rs. 0.75/unit
iii) For next 100 units Rs. 1.20/unit
iv) For unit above 250 Rs. 1.50/unit * Add fuel surcharge 20% and Govt. Tax 10% on bill to calculate the total bill.
4. Write a C program that displays the recommended actions depending on the color of a traffic light using the if statement..
True/false
3. A float constant cannot be used as a case constant in a switch statement.
11. It is necessary to have default case in a switch statement
13. Only character or integer can be used in switch statement.
21. Switch statements can also be used to switch on strings.
11. It is necessary to have default case in a switch statement
13. Only character or integer can be used in switch statement.
21. Switch statements can also be used to switch on strings.
Question
1. Explain switch-case with a suitable example.
2. Differentiate between if and switch statements
3. Write a program that displays the recommended actions depending on the color of a traffic light using the switch statement.
4. Output the following code:-
char c = 'f';
switch (c)
{
default:
printf("unknown colour ");
case 'r':
case 'R':
printf("Red ");
case 'g':
case 'G':
printf("Green ");
break;
case 'b':
case 'B':
printf("Blue");
}
5. Write a C program to find the square root of a given quadratic equation.
6. Write a program to find greatest number among 3 number.
7. Using a switch statement, write a function to count the number of vowels and number of blanks in a character array passed to it as an argument.
8. With the help of suitable example, explain the functioning of switch statement.
}
5. Write a C program to find the square root of a given quadratic equation.
6. Write a program to find greatest number among 3 number.
7. Using a switch statement, write a function to count the number of vowels and number of blanks in a character array passed to it as an argument.
8. With the help of suitable example, explain the functioning of switch statement.
16 Write a ‘C’ program to calculate the electricity bill using if..elseif, as per the following details * Given the number of units consumed, unit charges are as follows: i) For first 50 units Rs. 0.50/unit ii) For next 100 units Rs. 0.75/unit iii) For next 100 units Rs. 1.20/unit iv) For unit above 250 Rs. 1.50/unit * Add fuel surcharge 20% and Govt. Tax 10% on bill to calculate the total bill.
No comments:
Post a Comment