Programming in C model paper
Programming in C model paper
Anurag University
Max Marks: 30
Section – A
Answer all questions
(12 x 1 = 12 Marks)
1. Formulate the C – expression for the following arithmetic expression
+5 + 6x + 7
2. If the values of a, b and c are 120, 5 and 200 respectively, Find the value of the following C – expression
using precedence and associativity rules.
a + b * c /a
5. If
a=10;
b=a;
c=a++;
then the value of b is ----------- and value of c is ------------
6. Determine the value of the following logical expression when x=10, y=15 and z=20.
x! = yll y = = z -------------------
10. Identify the correct statement with respect to the size of the data types in C?
11. Identify the incorrect arithmetic expression from the following options
a) x += 10
b) x /= 10
c) x %= 10
d) x != 10
12. When the condition of the do-while loop is false, how many times will it execute the code?
a) 0
b) 1
c) Infinite
d) 10
Section—B
Answer any 6 questions
(3 x 6 =18 Marks)
13. Design a flowchart to check whether a given number is even or odd
15. Evaluate the expression step-by-step according to C’s precedence and associativity rules.
a = 5, b = 3, c = 8, d = 4, e = 2, f = 1, g = 6, h = 3
16. The following operations are performed sequentially, What are the values of x, y, z, and w after each
operation?
int x = 10;
int y = ++x; // Operation 1
int z = x--; // Operation 2
int w = x++ + --y; // Operation 3
17. Fill the blank blocks given in the flow chart to determine whether given number is positive, negative or
equal to zero
19. Arrange the lines of code to print the perfect number (Perfect number is sum of factors of the number is
equal to the number itself)
#include <stdio.h>
void main() {
int number, sum = 0;
printf("Enter a number: ");
scanf("%d", &number);
}
for (int i = 0; i < 1; i++) {
if (sum == number) {
printf("%d is a perfect number.\n", number);
}
}
for (int i = 1; i <= number / 2; i++) {
if (number % i == 0) {
sum += i; }
}
else {
printf("%d is not a perfect number.\n", number);
20. Design a C program that reads the number of roses each person has — Ram, Rahim, and Robin. Then,
determine and print the name of the person who has the highest number of roses. If there is a tie, print a
message indicating the tie.