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

CS101 Programming For Problem Solving (Mid - SP23)

The document provides instructions for a programming exam with 5 questions. It covers topics like pseudocode vs algorithms, binary conversion, amicable numbers, logical expressions, prime number decomposition, password validation, binary search, and set operations.

Uploaded by

TAG
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)
16 views2 pages

CS101 Programming For Problem Solving (Mid - SP23)

The document provides instructions for a programming exam with 5 questions. It covers topics like pseudocode vs algorithms, binary conversion, amicable numbers, logical expressions, prime number decomposition, password validation, binary search, and set operations.

Uploaded by

TAG
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

BIRLA INSTITUTE OF TECHNOLOGY, MESRA, RANCHI

(MID SEMESTER EXAMINATION SP2023)


CLASS: B. TECH / IMSC. SEMESTER: II
BRANCH: CSE/AI&ML/ECE/EEE/MATHS & COMP. SESSION: SP/2023

SUBJECT: CS101 PROGRAMMING FOR PROBLEM SOLVING


TIME: 02 Hours FULL MARKS: 25

INSTRUCTIONS:
1. The question paper contains 5 questions each of 5 marks and total 25 marks.
2. Attempt all questions.
3. The missing data, if any, may be assumed suitably.
4. Tables/Data handbook/Graph paper etc., if applicable, will be supplied to the candidates
-----------------------------------------------------------------------------------------------------------------------------
CO BL
Q.1(a) Compare Pseudocode with an algorithm for the Program Factorial of a Number. [2] CO2 BL4
Q.1(b) Write a C program to convert a decimal number into an equivalent binary number [3] CO1, BL3
using bitwise operators. C04

Q.2(a) Amicable numbers are found in pairs. A given pair of numbers is Amicable if the [2] CO1, BL3,
sum of the proper divisors (not including itself) of one number is equal to the other CO4 BL4
number and vice–versa.
For example, 220 &284 are amicable numbers.
First, we find the proper divisors of 220:
220:1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110
1+ 2 + 4 + 5 + 10 + 11 + 20 + 22 + 44 + 55 + 110 = 284
Now, 284: 1, 2, 4, 71, 142
1 + 2 + 4 + 71 + 142 = 220

Write a C program to check that the input pair of numbers is amicable.


Q.2(b) (I) Explain the differences between the source program, the object program, and [2+1=3] CO1, BL2,
an executable program. Which do you create, and which does the compiler create? CO3 BL3
Which does the linker or loader create?

(II) Given a= 10, b=5 and c=6, evaluate the following logical expression:
d= ((a < b) & & (b > c)) | | (a > c)

Q.3(a) How many lines of output does the following ‘C’ code produce? [2] CO3 BL4
#include<stdio.h>
float i=2.0;
float j=1.0;
float sum = 0.0;
main ()
{
while (i/j > 0.001)
{
j+=j;
sum=sum+(i/j);
printf("%f\n", sum);
}
}
Q.3(b) Write a program in C to check whether a number can be expressed as the sum of [3] CO1, BL3,
two prime. CO4 BL4
Test Data: CO5
Input a positive integer: 16
Expected Output:
16=1+15 // both are not prime
16=2+14 //2 is prime but 14 is not
16 = 3 + 13 // both are prime (ANS.)
16=4+12 //both are not prime
16 = 5 + 11 // both are prime (ANS.)
16=6+10 // both are not prime
16=7+9 // 7 is prime but 9 is not

PTO
Q.4(a) Write a C program to implement password registration, that accepts a string as [2] CO4, BL3,
password if it is at least 8 characters in length, has at least one capital letter, small CO5 BL4,
letter, digit, and a special character. BL6

Q.4(b) Write a C program to search a name in a list using binary search techniques. [3] CO5 BL3,
BL4

Q.5(a) Find the total number of swaps that take place when sorting the following set of [2] CO4 BL4
numbers using bubble sort. Show the passes in individual steps.

Location 1 2 3 4 5 6
Elements 33 77 46 99 12 56

For example, if the positions of 33 and 12 are interchanged, it is called one swap.

** Note: No program is required to be written for this question.


Q.5(b) Write a C program that takes 2 integer sets A [] and b [] as input and prints the [3] CO4, BL3
union between the two sets. CO5 BL4,
Note- All the elements in the output set should be unique. BL6
Input: A= [ 2,5,8], B= [8,8,3],
Output: C= [2,3,5,8]

::::::30/05/2023::::::M

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy