Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Mid Semester Test

B.Sc. (Hons.) First Semester


Paper: CS101T (Problem Solving through C Programming)

Max. Marks: 20 Max. Time: 1:30 hours

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 ) ;
}
}

c. void main() d. void main()


{ {
int a=2,b=1,c,d; int a=14,b,c;
c=a<b; a=a%5;
d=(a>b)&&(c<b) ; b=a/3;
printf("c = %d, d= %d\n”,c,d) ; c=a/5%3;
} printf ("a= %d, b=%d, c =%d\n",a,b,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)

You might also like