Programming and Problem Solving
CSE · Quiz · Summer 26
Read the questions as text
Read off the PDF by AI, so it may have mistakes. The PDF is the original.
Diffodil International University
Faculty of Science & Information Technology
Department of Computer Science and Engineering
Quiz-01
Course Code: CSE113, Course Title: Programming and Problem solving
Marks: 15
Time: 30 minutes
1. Find the operator and their types below given code. 4
1. #include <stdio.h>
2. int main() {
3. int x = 15;
4. int y = 5;
5. int output;
6. printf("Initializes x to %d and y to %d\n\n", x, y);
7. output = x - y;
8. printf(" %d - %d = %d\n\n", x, y, output);
9. if (y < x) {
10. printf(" %d is less than %d (True)\n\n", y, x);
11. }
12. if (x < 10 || y > 0) {
13. printf(" At least one condition is true\n\n");
14. }
15. printf(" x before decrement: %d\n\n", x);
16. x--;
17. printf(" x after decrement: %d\n\n", x);
18. int bo = x | y;
19. printf(" %d | %d = %d\n\n", x, y, bo);
20. int min = (x < y) ? x : y;
21. printf(" Min value between %d and %d is %d\n\n", x, y, min);
22. return 0;
23. }
2. Find the output of the program.
1. #include <stdio.h>
2. int main() {
3. int x = 5;
4. int y = 2;
5. switch (x - y * 2) {
6. default:
7. printf("Yellow ");
8. case 0:
9. printf("Red ");
10. break;
11. case 1:
12. printf("Green ");
13. break;
14. case 2:
15. printf("Blue ");
16. }
17. return 0;
18. }
3. Write a C program that optimizes water management by reading three inputs—soil moisture percentage (float), ambient temperature in °C (float), and rain sensor status (1 for raining, 0 for dry)—to print the final operational state of an irrigation network. If the rain sensor is active (1), the system must immediately stop and print "IRRIGATION DISABLED" regardless of other values; however, if it is dry (0), the program checks soil moisture such that if moisture falls below 30.0% with temperatures above 35.0°C, it prints "MAXIMUM FLOW ACTIVE", whereas if moisture is below 30.0% but the temperature is 35.0°C or lower, it prints "MODERATE FLOW ACTIVE", and for any moisture level between 30.0% and 60.0% inclusive, it checks if the temperature exceeds 30.0°C to print "ECO MODE ACTIVE" or otherwise prints "SYSTEM IDLE STANDBY" for all other safe moisture configurations above 30.0%. 4
Input:
- First line one float M(Moisture)
- Second line one float number T(Temperature)
- Third line one integer number R(Rain Status)
Output:
- As per given instructions. Don't forget the new line.
Sample Input | Sample Output
32.5 | ECO MODE ACTIVE
34.0 |
0 |
4. Write a C program for a vending machine that reads an integer choice (1 for Tea, 2 for Coffee, 3 for Juice) and prints the correct price using a switch-case statement. If the user types 1, the program prints "Tea selected: Price is 20 BDT"; if the user types 2, it prints "Coffee selected: Price is 40 BDT"; if the user types 3, it prints "Juice selected: Price is 50 BDT"; if the user types any other number, the default case must trigger and print "Error: Item Out of Stock". 4
Input:
- Input a single integer C(Choice)
Output:
- As per given instructions. Don't forget the new line.
Sample Input | Sample Output
2 | Coffee selected: Price is 40 BDT