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

3

The document outlines the makeup examination details for the Odd Semester of December 2023 for the B. Tech. program in the Department of First Year. It includes various sections with questions related to C programming, algorithms, flowcharts, and debugging tasks. The exam consists of multiple-choice questions, programming tasks, and analytical questions, all aimed at assessing students' understanding of problem-solving using computers.

Uploaded by

nevaidhyasingh
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)
17 views4 pages

3

The document outlines the makeup examination details for the Odd Semester of December 2023 for the B. Tech. program in the Department of First Year. It includes various sections with questions related to C programming, algorithms, flowcharts, and debugging tasks. The exam consists of multiple-choice questions, programming tasks, and analytical questions, all aimed at assessing students' understanding of problem-solving using computers.

Uploaded by

nevaidhyasingh
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

Name:

Enrolment No:

Odd Semester, Makeup Examination, December 2023


Department of First Year
B. Tech. – All Branches
Course Code: CS1002 Course: Problem Solving Using Computers Semester: I
Time: 03 hrs. Max. Marks: 80
Instructions: All questions are compulsory.
Missing data, if any, may be assumed suitably.
Calculator is not allowed.
SECTION A
S. No. Marks CO
Q A1 Predict the output of the following program:
# include <stdio.h>
int main()
{
int x = 2, y = 5;
2 CO2
(x & y) ? printf("True ") : printf("False ");
(x && y) ? printf("True ") : printf("False ");
return 0;
}

Q A2 Predict the output of the following program:

int main()
{
2 CO2
float x = 'a';
printf("%.0f", x);
return 0;
}
Q A3 Draw a flow chart to get a number from user and determine given number is odd or
2 CO1
even?
Q A4 Predict the output of the following C code:
int main() {
int num = 6;
int result = num << 2;
int result1=num>>2; 2 CO2
printf("After left shift by 2 bits:result= %d\n", result);
printf("After left shift by 2 bits: result1=%d\n", result1);
return 0;
}
Q A5 What is a pointer in the context of C programming? Provide a concise definition. Also
write the size of a character pointer and size of an integer pointer on a 32-bit system.
2 CO4

Page 1 of 4
SECTION B
Q B1 Write a C program that performs the following tasks sequentially.
#include <stdio.h>
int main()
{
/*
• Declare a variable named ‘temperature’ of type ‘double’.
• Read the value of ‘temperature’ from user.
• Prints one the following messages based upon the value of ‘temperature’ 6 CO3
(i) Prints “Freezing Weather” if ‘temperature is less than 0
(ii) Prints “Very Cold Weather” if 0 <= temperature <10
(iii) Prints “Cold Weather” if 10 <= temperature <20
(iv) prints “Normal Weather” if temperature >= 20
*/
}// End of Main

Q B2 Explain two major differences between an algorithm and a flowchart. Additionally,


outline the criteria for writing a good algorithm. 6 CO1

Q B3 Write a C program which performs the following tasks sequentially.


a. Declare a string variable named ‘subject’ with a capacity of 100.
b. Using input function read the string value as “Problem Solving Using
Computers”. 6 CO4
c. Determine the length of string using string library function.
d. Determine the frequency of the character 'o' in the string and display the count
of it.
Q B4 Explain the difference between "Call by Value" and "Call by Reference" in the
6 CO4
context of function parameter passing. Provide an example to illustrate each concept.
Q B5 #include"stdio.h"
int fun1(int *,int *);
void main()
{
int a=10,b=20,z;
int *p,*q;
p=&a,q=&b;
z=fun1(p,q);
printf("a=%d b=%d p=%d q=%d,\n",a,b,*p,*q);
printf("z=%d\n",z++);
}
int fun1(int *m,int *n) 6 CO4
{
int temp=0,sum=0;
temp=*m;
*m=*n;
*n=temp;
sum=*m+*n;
printf("m=%d n=%d sum=%d\n",*m,*n,sum);
return sum;}
(i) What value of m,n,sum will be printed?
(ii) What value of a,b,p,q will be printed?
(iii) What value of z will be printed
Page 2 of 4
SECTION-C (Analytical Based Questions)
Q C1 Debug and complete the following C program, which is designed to find the product
of the first five prime numbers.
#include <stdio.h>
int main() {
int primes[] = {2, 3, 5, 7, 11};
int product = 1;
// Debug and fix the issues in the for loop
for (int i = 0; i < sizeof(primes); i++) {
product *= primes[i]; }
// Missing logic: Complete the code to display the product of the first five prime
numbers
return 0;}
Issues to Address: 10 CO3
a. Identify and correct the error in the loop condition that may lead to accessing
memory beyond the array bounds.
b. Debug any logical errors preventing the correct calculation of the product of
the first five prime numbers.
c. Explain why the original loop condition was incorrect and how your
correction addresses the issue.
d. Suggest an alternative loop condition that would also work correctly for
iterating through the array.
Complete the missing logic in the code to display the product of the first five prime
numbers correctly.

Q C2 Write a C program that accomplishes the following tasks step by step:


a. Declare three 2-D arrays named "K1," "K2," and "K3" of type "int" with
dimensions 2*2.
b. Read the values for the 2-D arrays "K1" and "K2."
c. Multiply the corresponding elements of "K1" and "K2" and store the results in
the 2-D array "K3."
d. Display the contents of the resulting 2-D array "K3."
Ensure the program is structured to perform these tasks sequentially and provide the 10 CO4
code for each step.

Page 3 of 4
SECTION-D
Q D1 Consider a scenario where you are tasked with developing a program in C to manage
a library's book inventory. The program should utilize structures to handle book
information. The program should perform the following tasks:
a. Define a structure named Book with the following attributes:
Book _ID (integer) 10 CO5
Title (string)
Price (float)
b. Create a structure to store information of 2 books in the library.
c. Display the information of both Books.
Q D2 Debug and complete the following C program, which intends to calculate the factorial
of a given number using a while loop.
#include <stdio.h>
int main() {
int number, factorial;
// Missing logic: Complete the code to ask the user for input and store it in
'number'
// Debug and fix the issues in the while loop
while (i <= number) {
factorial *= i;
}
// Missing logic: Complete the code to display the factorial
return 0; 10 CO3
}
a. Identify and correct the error in the while loop that leads to incorrect factorial
calculation.
b. Debug any logical errors preventing the correct determination of the factorial
within the while loop.
c. Explain why the original while loop was incorrect and how your correction
addresses the issue.
d. Suggest an alternative loop construct that could be used instead of the while
loop to achieve the same result.
e. Complete the missing logic in the code to ask the user for input and store it in
the variable 'number', and display the calculated factorial at the end.

Page 4 of 4

You might also like