0% found this document useful (0 votes)
64 views2 pages

CSE-105 MID (Extra) Question

The document outlines a mid-term exam for a computer science course, focusing on structured programming language concepts. It includes three questions: defining arrays and analyzing a code snippet, writing output for a student ID processing code, and developing a C program to calculate room temperatures based on AC and heater settings in a grid. The exam is designed to assess students' understanding of programming and problem-solving skills in a structured format.
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)
64 views2 pages

CSE-105 MID (Extra) Question

The document outlines a mid-term exam for a computer science course, focusing on structured programming language concepts. It includes three questions: defining arrays and analyzing a code snippet, writing output for a student ID processing code, and developing a C program to calculate room temperatures based on AC and heater settings in a grid. The exam is designed to assess students' understanding of programming and problem-solving skills in a structured format.
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/ 2

Military Institute of Science & Technology (MIST)

Department of Computer Science and Engineering


MID term (Extra), Course: CSE 105: Structured Programming Language
Time: 45 minutes ​ ​ ​ ​ ​ ​ ​ ​ ​ Marks: 30

No Question Marks

1. Define Array and list the benefits of an array. Analyze the following code snippet and explain 4+4
the problem of this code. (CO-1)

1 #include<stdio.h>
2 int main()
3 {
4 int arr[5];
5 for(int i=0;i<7;i++)
6 {
7 int s=arr[i];
8 printf(“%d “,s);
9 }
10 }

2. Give your student id as input in the following code. Then just write the output of the code for 10
your input serially.​ ​ ​ ​ ​ ​ ​ ​ ​ ​
1 #include <stdio.h>
2 int main() {
3 int id, i = 0, rev = 0, sum = 0;
4 printf("Enter your student ID: ");
5 scanf("%d", &id);
6
7 while (id != 0) {
8 int last_d = id % 10;
9 if (i % 2 == 0)
10 {
11 sum += last_d;
12 printf("%d is at %d position from back in %d\n", last_d, i, id);
13 }
14 else
15 {
16 rev = rev * 10 + last_d * i;
17 }
18 i++;
19 id = id / 10;
20 }
21 printf("Final value of sum is : %d\n", sum);
22 printf("Reversed number after processing: %d\n", rev);
23
24 return 0;
25 }

3 12
A new single-storeyed building has been constructed for the Department of Computer Science (CO-1)
and Engineering of MIST. All the classrooms are on the same floor, arranged in an N x N grid.
Each room has a single AC, which decreases the room temperature, and a single heater, which
increases the room temperature. However, each of the N x N ACs and heaters changes the
temperature by a different amount, and this information is stored in the Central Temperature
Control System’s database as two N x N grids of integers.

Muhib is obsessed with the concept of heat transfer. So, he hacked into the Central Temperature
Control System and got access to the two N x N grids of integers that show by how many
degrees of Celsius, each room’s temperature is affected due to the AC and the heater in the
room respectively. Now, he has turned on both the AC and the heater in each room at the same
time and wants to calculate the room temperature. But, he does not like programming so he has
asked for your help.

Develop a C program that will take two N x N grids of integers as input i.e. the amount by
which each of the ACs and heaters change the room temperature respectively. Output, an N x N
Military Institute of Science & Technology (MIST)
Department of Computer Science and Engineering
MID term (Extra), Course: CSE 105: Structured Programming Language
grid of integers i.e. the room temperature of each room if both the ACs and the heaters are
turned on at the same time. You may assume the initial room temperature of each room to be 25
degrees Celsius when both the AC and the heater are turned off.

Given an example where N = 3 below:

1 2 3 19 12 1 43 35 23

3 5 9 3 2 4 25 22 20

11 7 15 8 2 15 22 20 25
Final room temperature of
The amount by which ACs Amount by which heaters each room if both the ACs
decrease room temperature increase room temperature and heaters are turned on at
the same time

You might also like