Page 1 of 2 Daffodil International University Department of Computer Science and Engineering Faculty of Science & Information Technology Final Examination ( Improvement - Overlap ) , Spring 2022 Course Code: CSE1 13 (Day ) , Course Title: Programming & Problem Solving Sections : P , Q, R , Teacher : KD Time: 2:00 Hrs Marks: 4 0 Answer ALL Questions [ The figures in the right margin indicate the full marks and corresponding c ourse outcomes. All portions of each question must be answered sequentially. ] 1. a) Show the errors in the following code and rewrite the full code after correction. #include <stdio.h> struc covid{ int firstDoseDate ; secondDoseDate ; boosterDoseDate; } moderna ; astraZeneca; int main() { struct covid moderna; moderna.firstDoseDate = 10; moderna.secondDoseDate = 19; moderna.boosterDoseDate = 31; astraZeneca = = moderna; astraZeneca = {10,11,12}; printf(" I have taken First Dose on %d March, 2022. \ n", astraZeneca.firstDoseDate); printf(" Then the 2nd Dose on %d March, 2022. \ n", astraZeneca.secondDoseDate ); printf(" And the Booster Dose on %d March, 2022. \ n", astraZeneca.boosterDoseDate ); return 0; } 5 CO 2 2. Build output for each of the following program a) #include < stdio.h > int main( ) { int num [5] = { 10, 20, 30, 40, 50 }; int *pointer = num + 2; printf ( "Pointer is pointing at %d \ n", *pointer ); printf ( "The array has started at %d \ n", *num ); return 0; } 2.5 CO 3 b) #include < stdio.h > int fun ( int val ) { if ( val = = 0 ) return 1; return 2 * fun ( val - 1 ); } int main( ) { int num = 5; int res = fun ( num ); printf ( "Result = %d \ n", res ); return 0; } 2.5 Page 2 of 2 3. Discover a full C Program for each of the following problems and write them : CO 4 a ) An old farmer have N lands. He knows the value of each land individually. One day a rich person came to him and told that he wants to buy all the lands of that farmer. What will be price? But the farmer could not tell him the exact price in total. Now write a full C program to help the farmer to find the total value of his lands. Input: An Integer N, number of lands the farmer have. Followed by N integers in the next line, each defines the price of a land. Output: “The Value is X” where X is the total price of all the lands. Sample Input Sample Output 5 70 80 40 30 20 Total Value is 240 6 b ) Two friends started playing a game called “Ok - World”. In this game you will be given a sentence where the characters will always be in between a to z. To win the game you have to count the total number of “ok” that appeared in the given sentence. Sample Input Sample Output i am ok are you ok is all ok okay 4 6 c ) Given a decimal number you have to write a full program to find out the equivalent binary number. Input: An Integer N (0 < N < 50000) defining the decimal value. Output: Equivalent binary value of N Sample Input Sample Output 19 10011 6 d ) We all studied Times Table in our childhood. Now to you will be given two integers N & M where N < M . You have write a program that will print all the times table from N to M. After each times table an empty line have to be printed. Sample Input Sample Output 3 3 3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 x 7 = 21 3 x 8 = 24 3 x 9 = 27 3 x 10 = 30 6 e ) One day a mathematician provided the following sequence: 1 2 3 6 36 648 ........... Here the first three numbers are fixed and then each number the multiplication of previous three numbers. For example the 4 th number is the multiplication of the fi rst three numbers (1 * 2 * 3 = 6). Now write a full C program using recursion to find the Nth number from the given sequence. Input: An Integer N (0 < N < 100). Output: Nth number from the given sequence. Sample Input Sample Output 6 648 6