0% found this document useful (0 votes)
11 views3 pages

PPS Fall2023 Final

Uploaded by

efaz444ahmed
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)
11 views3 pages

PPS Fall2023 Final

Uploaded by

efaz444ahmed
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/ 3

For more questions: https://diuqbank.

com | Uploader: Syed Mahi Hossen

Daffodil International University


Departmentof ComputerScience & Engineering
Faculty of Science & Information Technology
Final Term Examination Semester: Fall 2023
Course Code: CSE 113 Course Title: Programming & Problem Solving
Level:1 Term:1 Batch: 65
Time: 2.0 hourS Full Marks: 40

Answerall of thefollowingQuestions
[6] C02
Q1. DemonstrateError Finding & Bug Fixing:
3
a) Mention how many errors you can find in the followingcode. Explain the errors as per
your understandingwith line no. and why you think it as an error.
1 #include<Stdio.h>
2 struct employee
3 { int id,
4 float salary;
5. }:
6 int main()
7. {
8 employee el,e2;
9 el.id=2001;elsalary-90,
10. e2.id-2002;e2.salary-80;
11. printf( "Firstemployee id: %d &salary: %dn", el.id,el->salary);
12. printf( "Second employee id:%f &salary: 9%fn", e2>id,e2.salary);
13. retum 20:
14.
3
b) Construct the code without any errors.
91 CO3
Q2. Construct the Output for the given codes below (write only the output segment in a box):
a) b)
#include<stdio.h> #include<stdio.h>
void hel(int x) int main()

while(x--= 0) { int m-20,n=30:


printf("Nholo %dn"x*x); int *p,*q;
X+t; } p-&n,g&m;
returm; *p *= m, *q *=n;
3
printf("m-%dn=%dn",*q.n);
int main() printf("p=%dq=%dn",*p,m); +
return 0;
int n=10;
3
hel(n);
return 0:

c)
#include<stdio.h> 3
int main()
{
int ar[3][3]-{{5,2,3},{2,1,3}.{2,22}}.ij;
for(i-0;i<3;i++)
for(j=ij<3;jtt)
printf("I=%dJ=%dn, arliJi]*i,ar[il[i);

GO0D LVCK
For more questions: https://diuqbank.com | Uploader: Syed Mahi Hossen

C04
Q3. Analyze the problem scenariosgiven below to write a full program for each of the following| [25]
a) Recently Apple released the Iphone 15Series. They launched three mobile phonesof 15 series: 5
Iphone 15, Iphone 15 pro & Iphone 15 pro max. But one of the saddest things about these phones
is that Appledoes not provide a chargerwith the mobile. The user has to buya charger externally.
Mr. Tamim Iqbal is the former captain of "Mayer Doa Cricket Team" is going to be the captain
again after the world cup. In these circumstanceshe wants to buy a new Iphone from the 15 series
as he is a fan of the Iphone. But he does not have enough money to buy an original charger with
the mobile, as he did not get the salary of the previous month from the "Mayer Doa Cricket
Board". So, he planned to buy a duplicate charger that was manufacturedby china. There are
three types of charger that China manufacturedfor the Iphone 15 series. You have to help Tamim
Iqbal by finding the cheapestone from them.
Input: There will be three integers that are the prices of the three chargers.
Output: Show the cheapestprice of the charger.
Sample Input Sample Output
2000 5000 1500 1500

b) To qualify Main Round of Take-Off Programming Contest you have to participate in the
preliminary round. There are some criteria by which the students are selected from preliminary
round to main round. You go through the rules and you find that it is complex to calculate. You
don't want to do the complex calculation and you make a rule for yourself that by maintaining the
rule you believe that you can qualify to the main round. The rule is you have to solve a minimum
number of problems to qualify in the main round.
Input: In the first line you have to take an integernumber N, representingthe number of problems
in the contest. In the next line you have to input N integers that represent the problems' verdicts (
here 1 means you got accepted on the problem and 0 means you got the wrong answer).
The last line there will be an integer X, that represents the minimum number of problems you
have to solve to qualify for the main round.
Output: Show "es, I Will qualify!" if you have qualified for the main round, otherwise show "I
am sorry!".
Sample Input Sample Output
Yes, IWill qualify!
10111 1
4
6 Iam sorry!
10100 1
4

Explanation:In the first sample you have solved5 problems and the number of problemcounts to qualify in
the main round was 4, so you qualifiedfor the contest.

So, Almost you have completedthe Programmingand Problem SolvingCourse. Advanced| 5


Congratulationsif you will pass this course. You tried hard and practiced problems each day and
performed very well. Iam your course teacher in this course and Iwant to give you an opportunity
to get an experience of Student prefect with me in the next semester. I want to give a prize to my
section's students based on the weekly performancesin the next semester to notivate the students.
As you are the best programmerof the previous course, Iam given the responsibilityto find out
the best weekly performance. You will be given the day wise problem solve count of a week of
students of theclass serially from roll 1, you have to find out the best one.

GooD LVCK (
For more questions: https://diuqbank.com | Uploader: Syed Mahi Hossen

Input: In the first line there willbe an integer N, the number of students in the class. Then there
will be N lines and each line willcontain 7 integers that are the solvc count of 7 days of the
students.
Output: Show the student rollnumber, who have solved themost problems in the format "Roll -
X is performerof the week.", where X is the roll number.
Sample Input Sample Output
3 Roll-3 is performer of the week.
2301011
4 111111
32 41011
Explanation:
Roll-1student solve count =8.
Roll-2 student solve count = 10.
Roll-3 student solve count = 12.

d) Recentlyyou are learningCProgramminglanguageand your teachertaught you anew topic 5


about String. String is the combinationof multiple characters,digits or symbols. As your teacher
taught you about string already so he gives you a task. He told you to pick a name and gave you
two charactersX, Yand told you from that name you have to replace all the Xwith Y. As you are a
good programmer and doing good at programming, he expects youto solve this problem and
satisfy him.
Input: In the first line there will be a string S (it will have no space and contains only uppercase
and lowercasecharacters).In the next two lines there will be two charactersX and Y.
Output: You have to print a new string from S replacingcharacterX by character Y( For more
clarification see the sample input output)
Sample Input Sample Output
MehedyHasanMiraz MehedyHesenMirez

Explanation:In the Sample Input, you have to replace allthe characters'a' with 'e' in the string.
5
e) From childhood you love digits. You love to play with digits. Recently you have learned
about programmingand are learning more and more new topics in programminglanguages.Today
your teacher has teached you about recursion. Recursion is one of the most fascinatingtopics in
programming because when you think about a problem and want to solve it with recursionyou
need to make your own imaginary visualizationof how it can manipulate your code using a few
lines of code.As you love digits and learn about recursion you want to solve a Sum Of Digit
problem using recursion. You have already solved this problem using loop but now as you learn
about recursion you want to solve this problem using recursion.You don't need to do many things.
All you have to do is You will be given a number N. You have to do a sum of all digits of this
number N(using recursion)and show the result as output.
Input: You are given a number N.
Output: Print the sum of the digits ofN(usingrecursion)
Sample Input Sample Output
54321 15

GOOD LCK (

You might also like