Professional Documents
Culture Documents
Mody University of Science and Technology Faculty of Engineering and Technology
Mody University of Science and Technology Faculty of Engineering and Technology
Instruction to candidates:
1. All questions are compulsory and carry equal marks.
Q.1 What would be the output of following code? [ 1*5=5 ]
( a ) #include<stdio.h>
void main() { if(!5)
printf(“Teachers”);
else
printf(“Students”);
}
( b ) #include<stdio.h>
void main() { int x=2;
switch(x%2)
{ case 1: printf(“Cakes”);
case 2:printf(“Chocolates”);
default: printf(“Pizza”);
}}
( c ) #include<stdio.h>
void main() {
int a=5,b=0,c;
c = a ||b;
printf(“%d”,++c);
}
( d ) #include<stdio.h>
void main() { int i;
for(i=0;i<10;i=i+2);
printf(“%d”,i);
}
( e ) #include<stdio.h>
void main() { while (1)
printf(“ Mody University\n”);
}
1/2
Q.2 ( i ) The voter’s eligibility age in our country is 18 years. Write a program to input the age of a
person and print whether the person is eligible to vote or not. [3]
INPUT : 19
OUTPUT: Eligible to vote
( ii ) A restaurant outside your campus offers discount of 10% on every food item. Write a program
to input the original cost of the food item and calculate the cost after discount. Print the
discounted price. [2]
INPUT : 100
OUTPUT:90
Q.3 Write a program to input a number and print the even digits of the number. [5]
INPUT : 12345
OUTPUT: 2 4
Q.4 Write a program to input age of three persons and find out the middle age. [5]
INPUT : 19 17 21
OUTPUT: 19
2/2