0% found this document useful (0 votes)
9 views4 pages

Question MidSem

Uploaded by

Sahil Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Question MidSem

Uploaded by

Sahil Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CSO 101: Computer Programming

Mid Semester Exam


Answer All Questions

23th March 2022 Maximum Marks 100


Instructions:
1. A separate assignment tab has been created for mid-semester in the MS Teams class.
Write your answers on paper, scan and then submit in this assignment tab of MS Teams
before tomorrow 24th March, 8:00 AM. Answer sheet must be a single pdf file. A copy
of the answer sheet should also be sent to [email protected].
2. Do not forget to mention your Roll number, Section, Name, and Branch in the answer
sheet. The name of the submitted copy should be your roll number.
___________________________________________________________________________
Q1. Discuss major differences between Compiler and Interpreter. [5]

Q2. Discuss major differences between Algorithm, Pseudocode and Program. [5]

Q3. Define the Operating System along with major functions of it. [5]

Q4. Discuss Various Programming Paradigms. [5]

Q5. Answer following questions: [5]


a) Why and when do we use the #include directive?
b) Why do we need to use comments in program?
Q6. Describe the structure of a C program. Also write features of c? [5]
Q7. What are various types of programming language? What is the difference between
Imperative programming language and Declarative programming language? [5]
Q8. What does void main(void) mean? [5]
Distinguish between the following pairs:
a) main() and void main(void)
b) int main() and void main()

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]

Q13. What are the different assignment operators? Explain. [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);

b. printf(“%7.2f ", y);

c. printf(“%-7.4f ", y);

d. printf(“%f ", 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

Q19. Write the output from the following program: [1+1+2]


#include <stdio.h>
int main() {
int w = 0, x = 2.5, y = 5, z = 3, r, s = 4, t = 5, u = -3;
double a = 2.36, b = 3.19, c = 3.0, d = 2.91726;
printf("Expr_1 = %d\n", (int)(c * y / z + y / z * c));
printf("Expr_2 = %lf\n", x - s * t * - c - u);
printf("Expr_3 = %f\n",
(float)(x + y < z + w && a > b - 17 * x || ! x < 5));
return 0;
}

Expr_1 = __________
Expr_2 = __________
Expr_3 = __________

Q20. Write the output of the following program. [1+1]


#include <stdio.h>
#define m 5+5
const int n = 5+5;
void main() {
int a = 0, b = 0;
a = m * m;
b = n * n;
printf("%d %d\n", a, b);
}

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

You might also like