Programming Mid Semester Exam 2024 - UES103 PDF

Summary

This is a programming exam from Thapar Institute of Engineering and Technology for the 2024 academic year. The exam covers topics such as flowcharts, binary conversion, array manipulation, and programming logic. It features multiple questions, including those on 1-D and 2-D arrays, ternary operators, and simple calculator.

Full Transcript

Thapar Institute of Engineering and Technology, Patiala Computer Science and Engineering Department Mid Semester Examination (MST) 2023-24 Even Semester B.E. II Sem Course Name: Programming for Problem Solving Course Code: UES103...

Thapar Institute of Engineering and Technology, Patiala Computer Science and Engineering Department Mid Semester Examination (MST) 2023-24 Even Semester B.E. II Sem Course Name: Programming for Problem Solving Course Code: UES103 Date: 19th March, 2024 Time:11:00AM-1:00PM Maximum Marks: 30 Faculty: Raman, Ravneet, Saif, Rahul, Seemu, Deep Mann, Tanu, Himika, Mahak, Saurabh Q1. a) Draw a flowchart to fmd the greatest of three numbers. (3marks) b) A 4-bit binary number has 2 zeros and 2 ones. (2marks) (i) List all the possible binary numbers with these digits (ii) Convert these numbers to decimal (base 10). c) Write a C program to search an element in one-dimensional array using Binary Search. (5marks) Assume that array is already sorted in ascending order. Q2. a) Write a program to take a number as input from user and generate a new number by replacing all 0's with 1's in the number. For example, if number =201301, the resultant (5marks) number should be 211311. (Make sure to store the resultant number in a variable and print the value of that variable as output..) b) Write a program in C to fmd whether the number is odd or even using ternary operator. (2marks) c) Write a program using switch case to build a simple calculator with + (addition) — (3marks) (Subtraction) * (multiplication) and / (division) operations. Program should run as follows: Program should run multiple times and every time it should take a character input from user as Y or N. If the user input Y, program should ask user to enter two numbers and a character input as + - * or / and accordingly perform the said operation. It should stop executing whenever a user enters N. Q3. a) Write a program to take (n x m) 2-D array from user. User wants to insert a new element in this 2-D array. Ask user to input the row and column number where the new (5marks) value has to be inserted. You have to insert the new value preserving the previous values i.e. new value should be inserted and all other values should be shifted one position ahead. (As the array size will increase after insertion so make sure to initially take the size of array accordingly. Also, after insertion, if there is a new row that will be inserted in the new array, all the trailing elements should be reflected as 0 in that row) Example, Original Array: 1 2 3 456 789 Position entered by user: 2,3 and value is 28 Output: 1 23 4528 678 90 0 b) Write a program to take a string with spaces as input from user. Program should interchange (swap) only the second and third words of the string keeping other part of (5marks) the string intact. For example: Input= "I am studying programming" Output= "I studying am programming:

Use Quizgecko on...
Browser
Browser