Skip to content

Programming and Problem Solving

CSE · Final · Fall 21

Section All

This browser can’t show the PDF here

Open it, and your phone’s PDF viewer takes it, or download it.

Read the questions as text

Read off the PDF by AI, so it may have mistakes. The PDF is the original.

Daffodil International University Department of Computer Science and Engineering Faculty of Science & Information Technology Final Examination, Semester: Fall 2021 Course Code: CSE122, Course Title: Programming and Problem Solving Section: All Instructor: All Two hours (2:00) Full Marks: 40 1. The following code generates errors. List the reasons? Modify the code and rewrite the corrected one. 2 x 5 = 10 a) int main() { int i; for(i=1; i<=10; i++) { if(i/2=0) printf("\n Index %d",i); printf("\n %d is Even",i); else printf("\n Index %d",i); printf("\n %d is Odd",i); } return 0; } b) You asked to write a program that will find the sum marks of 10 students using arrays. One student come up with the following solution, your task is to find out the errors in this program. int main() { int marks[10],i, sum; for(i=0; i<=10; i++) { printf("Enter mark:"); scanf("%d", marks[i]); sum =sum+marks[]; } printf("Sum= %d", marks); return 0; } 2. Write a full C Program for each of the following problems: 6 x 5 = 30 a) Let us start with an easy problem to start this Section! Write a C program that calculate and display the average and sum of three numbers A, B and C. Notes: value for A, B and C will be the input from the user. b) Create a C structure Scientist to hold the following items: - Name of the Scientist: Can be at max 10 characters (i.e. Albert Einstein) - Age of the Scientist: A float value( i.e. 78.5) - Number of Publications: An integer value (i.e. 53) Now declare "sntst1" and "sntst2" of the struct Scientist type and assign some imaginary value to those variables and print out those values. c) Take a String from user as input and print that string in reverse. Sample Input: DIU CSE Sample Output: ESC UID d) There is a function named fun who takes an integer number n as input and print all the number in the range of 1 to n. Now write a complete c program including fun and main function. Sample Input: 7 Sample Output: 1 2 3 4 5 6 7 e) Take 5 inputs from the user and store them in a integer type single dimensional array x[ ] of size 5 and do the summation of all the odd elements of the array. Sample Input: 3 4 1 9 8 Sample Output: 13 f) Write a C program that will read a string and print the number of lower case vowels and consonants in it. Sample Input: I See Fire Sample Output: 4 vowels and 1 consonant