Question MidSem
Question MidSem
Q2. Discuss major differences between Algorithm, Pseudocode and Program. [5]
Q3. Define the Operating System along with major functions of it. [5]
Q9. Write a program to find smallest of three numbers using conditional operators. Mention
whether parentheses are necessary in the conditional expression and why? [4]
Q10. How does precedence and associativity play a role in evaluating an expression? Explain
[2]
Q11. How many passes and steps are required to evaluate this expression. Show the steps.
(4+(5))/(1*2)-(2*4) [5]
Q12. What are the differences between implicit and explicit type casting? [3]
Q14. What is the difference between post-fix and pre-fix operators? Explain with an example.
[3]
Q15. Write a program to enter a sentence “Hello. How are you?” from user strictly using
“scanf” and then print the sentence back to screen. [4]
Q16. Write a program to enter the date of birth from user strictly in the format of “DD-MM-
YYYY” using single “scanf” function. Assume user will enter valid input but strictly in the
format of DD-MM-YYYY only. [4]
Q17. What is the output of the following statements for input float y = 12.3456: [1.5x8]
a. printf(“%7.4f ", y);
e. printf(“%10.2e", y);
f. printf(“%11.4e", y);
g. printf(“%-10.2e", y);
h. printf(“%e", y);
Write “<space>” wherever there is a space for question Q17.
Q18. The following expression has a single pair of parentheses missing that makes it
syntactically wrong and it does not compile. Place a pair of parentheses in proper places to
correct the expression and evaluate it for x = 2, y = 3, z = 5, w = 7: [2+1]
x*w+y*z=7
Expr_1 = __________
Expr_2 = __________
Expr_3 = __________
Q21. Find the output of the given program? Write a justification for your answer. [2+2]
#include< stdio.h>
int main()
{
const float pi = 3.14;
pi = 3.14;
printf("%d", pi);
return 0;
}
Q22. Const variable is only for reading. We can’t modify the value of constant variable. [4]
Consider the following program:
#include<stdio.h>
int main()
{
int m, n;
printf("Supply two integers: ");
scanf("%d%d",&m,&n);
m = m - n;
n = m + n;
m = n - m;
printf("%d %d\n", m,n);
return 0;
}
Describe, in terms of the scanned integers m and n, what integer values are printed at the end
of the above program.
Q23. What is the output of this program? Write a justification for your answer. [3]
#include <stdio.h>
int main() {
int x = 10;
float x = 10.0;
printf("%d",x);
return 0;
}