Professional Documents
Culture Documents
Mid Semester Test CS101 2022
Mid Semester Test CS101 2022
Mid Semester Test CS101 2022
1. What will be the output of following codes? Explain your answer with proper reason.
(2x5=10)
a. void main()
b. void main()
{
{
float a = 5, b = 2;
int a=98;
int c;
char ch=' c' ;
c = a%b;
printf("%c, %d\n",a,ch);
printf ("%d", c ) ;
}
}
e. void main()
{
int a=15,b=13,c=16,x,y;
x=a-3%2+c*2/4%2+b/4;
y=a=b+5-b+9/3;
printf ("x = %d, y = %d\n", x, y) ;
}
2. Write a program to accept any number n and print the cube of all numbers from 1 to n
which are divisible by 3. (5)
3. Explain the difference between ‘while loop’ and ‘do while loop’ with suitable example. (5)