SRM Institute of Science and Technology College of Engineering and Technology

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Registration

Number

SRM Institute of Science and Technology


SET 2
College of Engineering and Technology
School of Computing
SRM Nagar, Kattankulathur – 603203, Chengalpattu District, Tamil Nadu
Academic Year: 2024-25 (ODD)

ANSWER KEY

Test: CT1 Date: 30-09-2024


Course Code & Title: 21CSS101J Programming for Problem Solving Duration: 1hr 40 mins
Year &Sem: I/I Max. Marks: 50

Course Articulation Matrix: (to be placed)

S.No Course PO PO2 PO3 PO4 PO5 PO6 PO PO PO9 PO1 PO11 PO12
Outcome 1 7 8 0
1 CO1 2 3 2
2 CO2 2 3 2
3 CO3 2 3 2
4 CO4 2 3 2
5 CO5 2 3 2

Course Outcomes (CO):

CO-1: Solve problems through computer programming. Express the basic data types and variables
in C
CO-2: Use appropriate data types in simple data processing applications. To create programs using
the concept of arrays.
Part A (10* 1 = 10 Marks)

Sl. Mark B C P PI
Question Code
No s L O O
1 C) bool 1 1 1 1 1.4.1

Answer is 50. Choice not given if attempted give the


2 mark
1 1 1 1 1.3.1

3 A) const int x = 10; 1 2 1 2 2.2.3

4 A) & 1 2 1 2 2.2.4

5 B) 10 1 2 1 2 2.4.1

6 A) 1 2 3 1 2 2 2 2.1.2

7 A) Greater than 5 1 2 2 2 2.4.2

8 B) int x = 5; 1 2 1 2 2.4.2

9 C) 11 1 2 1 2 2.4.2

10 B) 15 1 2 1 2 2.4.2
Part B (5 * 4 = 20 Marks)

M
Sl. B PI
Question ar CO PO
No ks
L Code
Illustrate the concept of operator precedence in C
through an example.

11 ● Operator precedence table (2) 4 2 1 1 1.4.1


● One simple expression evaluation example
(2)
You are tasked with devising an algorithm for a basic
calculator for a small grocery store to help the cashier
to calculate the total price of two items. The cashier
will input the price of both items, and your algorithm
should calculate and display the total cost.
Total 5 steps, the algorithm must input 2 values find
12 the total and display it. 4 3 1 1 1.4.1

● Reading input (1)

● Processing the data (2)

● Display output (1)


Debug the code and generate the output as return 0
or return 1.
#include<stdio.h>
int main()
{
int n;
long sum=0; delete this
printf(“Enter a positive integer:”);
scanf(“%d”,&n);
if(n<0)
{
printf(“Please enter a positive number
greater than zero.\n”); delete this
return 1; change this to printf(“return
13 0”); 4 3 2 2 2.3.1
}
else
{
printf(“return 0”);
}
for(i=1;i<n;i++)
{
sum+=i*i;
}
printf”(The sum of squares of the first %d
natural numbers is:%d\n”,n,sum); delete this
return 0;
}

14 Fill the code given and explain how the desired 4 3 2 2 2.4.2
output will be generated.
#include <stdio.h>
int main() {
int number;
printf("Enter a number: ");
scanf("%d", &number);
if (number> 0) { // Blank 1
printf("The number is positive.\n");
}
else if (number < 0) { // Blank 2
printf("The number is negative.\n");
}
else {
printf("The number is zero.\n"); // Blank 3
}
return 0;
}
You are working on a banking application that
requires a feature to help customers track their
daily expenses. The program should allow users to
input their daily expenses one at a time. When the
user enters a negative value, it indicates that they
have finished entering expenses for the day.
15 Implement using a C program to calculate and 4 3 2 4 2.4.2
display the total amount spent.
Algorithm(or)Program
User Input the expense (1)
Check for negative value to stop the input(1)
Find the total expense(1)
Display the final savings(1)

Part C (2 * 10 = 20 Marks)

M
a
Sl. PI
Question r BL CO PO
No k
Code
s
Design an algorithm and implement the same
using C program for carrying out the following
tasks
● Read yesterday’s and today’s temperature

● Find the difference

● Using an operator print “Increase” if


1
16 today’s temperature is higher and print 3 1 4 4.1.2
0
“Decrease” otherwise.
● Input 2 temperatures (2)

● Calculate the temperature difference(2)

● Use the ternary operator to check in


increase or decrease based on this display
the result(6)
(OR)
A company calculates the salary of an employee
based on the category of the employee. For daily
wage employees, their salary is based on the
number of hours worked and the rate per hour.
On the other hand, regular employees have a
more structured salary calculation, which takes
into account several components such as basic
pay, allowances, and additional benefits. For
example, a regular employee’s salary includes a
fixed basic pay, which is then increased based on
factors like a predefined percentage of Dearness
Allowance (DA), a specific House Rent
Allowance (HRA), and a medical allowance. 1
17 Each of these components contributes to the final 3 1 4 4.1.2
0
salary calculation. the correct calculation is
applied based on the employee type, with the
appropriate salary elements factored in for each
type of employee.
● User Input the employee type (1)

● Based on the employee type 1 or 2 input


the allowances(1)
● calculate the salary of the employee using
the ternary operator (6)
● Display the desired output (2)
You are developing a simple traffic light control
system. The system controls the flow of traffic at
an intersection. The lights can be:

Green: Vehicles can move.


Yellow: Vehicles should slow down.
Red: Vehicles must stop.
The traffic light's state is represented by three
flags:

isGreen, isYellow, and isRed (all are either 0 or


1). 1
18 Write a C program that takes the states of the 3 2 4 4.1.2
0
traffic lights as input and prints:

"Go" if the light is green.


"Slow Down" if the light is yellow.
"Stop" if the light is red. If more than one light is
on or no light is on, print "Invalid signal".
● Input the 3 state of lights (3)

● Use if-else or switch statements to check


and display which light is on(6)
● Display of output(1)
(OR)
Write a program that simulates an ATM withdrawal
process. Repeatedly ask the user to enter the amount
they want to withdraw until they enter a valid amount
that does not exceed their account balance.
● Initialize one variable for balance(1)
1
19 ● User input(1) 3 2 4 4.1.2
0
● Using do-while loop get the withdrawal
amount and check for valid amount using
if-else-if(7)
● Display the output(1)

Course Outcome (CO) and Bloom’s level (BL) Coverage in Questions

Blooms Level Coverage


CO Coverage %
70
60
50 13% BL1
40 BL2
30 42%
BL3
20
10 45%
0
CO1 CO2 CO3 CO4 CO5

CO Coverage %

You might also like