Full Transcript

22CS23 USN RV COLLEGE OF ENGINEERING® (An Autonomous Institution affiliated to VTU) II Semester B. E. Examinations October-2023 Common to AI / BT / CS / CY / CD / IS...

22CS23 USN RV COLLEGE OF ENGINEERING® (An Autonomous Institution affiliated to VTU) II Semester B. E. Examinations October-2023 Common to AI / BT / CS / CY / CD / IS PRINCIPLES OF PROGRAMMING USING C Time: 03 Hours Maximum Marks: 100 Instructions to candidates: 1. Answer all questions from Part A. Part A questions should be answered in first three pages of the answer book only. 2. Answer FIVE full questions from Part B. In Part B question number 2 and 11 are compulsory. Answer any one full question from 3 and 4, 5 and 6, 7 and 8, 9 and 10. PART-A 1 1.1 #include 𝑖𝑛𝑡 𝑚𝑎𝑖𝑛() { 𝑝𝑟𝑖𝑛𝑡𝑓("%𝑑" , 𝑝𝑟𝑖𝑛𝑡𝑓("%𝑑" , 1234)); 𝑟𝑒𝑡𝑢𝑟𝑛 0; } The output for the following program is __________. 01 1.2 List any two types of Errors. 01 1.3 𝑖𝑛𝑡 𝑎 = 5, 𝑏 = 7, 𝑐 = 12, 𝑑 = 15, 𝑥; Evaluate the given expression 𝑋 = + + 𝑎 + + + 𝑏 + + + 𝑐 + + + 𝑑; Print the values of 𝑥, 𝑎, 𝑏, 𝑐, 𝑑 after evaluation. 01 1.4 When 𝑎 = 12345 and 𝑏 = 678, write the output for the following code: 𝑠𝑐𝑎𝑛𝑓(“%2𝑑%5𝑑”, &𝑎, &𝑏); 𝑝𝑟𝑖𝑛𝑡𝑓(“\𝑛 𝑎 = %𝑑 𝑎𝑛𝑑 𝑏 = %𝑑”, 𝑎, 𝑏); 01 1.5 Mention various built-in functions along with its functionality supported for strings in 𝐶. 01 1.6 Analyze the following 𝐶 program and write the output. 𝑖𝑛𝑡 𝑚𝑎𝑖𝑛() { 𝑐ℎ𝑎𝑟 𝑎𝑟𝑟[] = {“𝑅𝑉𝐶𝐸”, “𝐵𝑀𝑆𝐶𝐸”, “𝑀𝑆𝑅𝐼𝑇”}; 𝑝𝑟𝑖𝑛𝑡𝑓(“%𝑠\𝑛”, 𝑎𝑟𝑟); 𝑝𝑟𝑖𝑛𝑡𝑓(“%𝑠\𝑛”, 𝑎𝑟𝑟); 𝑟𝑒𝑡𝑢𝑟𝑛 0; } 01 1.7 What is the output of the following code? #𝑖𝑛𝑐𝑙𝑢𝑑𝑒 < 𝑠𝑡𝑑𝑖𝑜. ℎ > 𝑠𝑡𝑟𝑢𝑐𝑡 𝑠𝑡𝑢𝑑𝑒𝑛𝑡 { }; 𝑣𝑜𝑖𝑑 𝑚𝑎𝑖𝑛() { 𝑠𝑡𝑟𝑢𝑐𝑡 𝑠𝑡𝑢𝑑𝑒𝑛𝑡 𝑠; 𝑝𝑟𝑖𝑛𝑡𝑓(“%𝑑”, 𝑠𝑖𝑧𝑒𝑜𝑓(𝑠)); } 01 1.8 What will be the output of the following program? #𝑖𝑛𝑐𝑙𝑢𝑑𝑒 < 𝑠𝑡𝑑𝑖𝑜. ℎ > 𝑖𝑛𝑡 𝑚𝑎𝑖𝑛() { 𝑐ℎ𝑎𝑟 𝑠𝑡𝑟 = “𝐻𝑒𝑙𝑙𝑜”; 𝑐ℎ𝑎𝑟 ∗ 𝑐𝑜𝑛𝑠𝑡 𝑝 = 𝑠𝑡𝑟; ∗ 𝑝 = ‘𝑀’; 𝑝𝑟𝑖𝑛𝑡𝑓(%𝑠\𝑛”, 𝑠𝑡𝑟); 𝑟𝑒𝑡𝑢𝑟𝑛 0; } 01 1.9 What is the purpose of 𝑓𝑠𝑒𝑒𝑘 function? 01 1.10 Give two differences between 𝑐𝑎𝑙𝑙𝑜𝑐() and 𝑚𝑎𝑙𝑙𝑜𝑐() functions. 01 PART-B 2 a Write an Algorithm and a Flowchart to print the sum of even terms contained within the numbers 0 to 20. 07 b Discuss the process of compiling and running a 𝐶 program with a neat diagram. 07 3 a Write a 𝐶 program to perform the following operations on a matrix: i) Read the elements of the matrix ii) Add the diagonal elements of a matrix. iii) Sum of all the elements of a Matrix. 06 b What is the difference between break and continue? Write a program to reverse a given integer number using a for loop and without using library functions 08 OR 4 a Write a program to recognize whether the given character is vowel or consonant using switch statement. 07 b Write a 𝐶 program to display the n terms of harmonic series and find their sum. Harmonic series: 1 + 1/2 + 1/3 + 1/4 + 1/5 …..1/𝑛 terms 07 5 a Write a 𝐶 program to check a string for palindrome using functions to find the length of the string and a function to check the string passed to function for palindrome. (Note Do not use any string handling functions) 10 b Describe global variables, local variables and their scope. 04 OR 6 a Write a 𝐶 program to sort the names by writing a function for sorting the names passed as an argument. 08 b Discuss different categories of 𝐶 functions with proper examples. 06 7 a Explain the arithmetic operations that can be carried out using a pointer with an example. 06 b What is typedef? Write a 𝐶 program using structures to add two complex numbers. Create a structure 𝐶𝑂𝑀𝑃𝐿𝐸𝑋, and a function AddCompNum() to add two complex numbers. 08 OR 8 a Briefly discuss why we need pointers and its advantages. Write a program in 𝐶 to find the length of the string Using Pointer. 07 b Write a 𝐶 Program that prints the 𝑋 − 𝑌 coordinate of two ends of a line using structure. 07 9 a Define dynamic memory allocation. Write a 𝐶 Program to demonstrate various Dynamic memory allocation and De-allocation functions used in 𝐶. 08 b Define linked list. Explain different types of linked list with an example. 06 OR 10 a Differentiate between static and dynamic memory allocation using a C program 08 b Explain the functions used in file operations with an example. 06 11 a Develop a 𝐶 program to compute average marks of ‘𝑛’ students (Name, Roll_No, Test Marks) and search a particular record based on ‘Roll_No’ 10 b Write a 𝐶 program to count number of lines, blank lines and comments in a given program using files. 10

Use Quizgecko on...
Browser
Browser