North South University: Department of Computer Science and Engineering
North South University: Department of Computer Science and Engineering
Instruction
Show all your work where necessary.
Submit .c files for programming question (Q4-Q7). Comment your program where
necessary. In addition, use comments to write your name and ID in the C file.
Put all your work in a folder and upload within the specified time limit. Plagiarism of any
form will be strictly handled.
Q2b) Trace the program, show how the variable value changes for every iteration and the show
the output of the code snippet from a C program. (2points)
{ int i = 0, j = 1;
while(i <= 6)
{ printf("\n%d \t %d", i, j);
i++;
j += 4;}}
North South University
Department of Computer Science and Engineering
Course: -CSE115
Mid Term Exam, Fall 2020, Time: 1 Hour 30 Minutes
Please answer all the questions, Total Points: 50
Q3) Modify the following code to produce the output shown. Use proper indentation techniques.
You may not make any changes other than inserting braces. The compiler ignores the
indentation in a program. We eliminated the indentation from the following code to make the
problem more challenging. [Note: It’s possible that no modification is necessary.] (5 points)
if ( y == 8 )
if ( x == 5 )
printf( "@@@@@\n" );
else
printf( "#####\n" );
printf( "$$$$$\n" );
printf( "&&&&&\n" );
Assuming x = 5 and y = 8, the following output is produced.
@@@@@
$$$$$
&&&&&
Q4) Due to financial problems, it was necessary for Bank A to cut customers’ credit limits in
quarter. So, if credit limit was Tk8000 previously, it’s now Tk2000. Write a program to find the
credit status of five customers given each customer’s account number, credit limit before
financial problem and customer’s current balance.
i) As a requirement for the design phase of the software, draw the flowchart and write pseudo
code for the problem stated above .(5 points)
ii) Write a full C programming based on the pseudo code you create.(5 points)
Expected Outputs: Print the new credit limit for each customer
Print if customers have current balances that exceed their new credit limits.
Q5) Write a C program to calculate the average of a set of integer numbers with values entered
one after the other. Use negative number at the end but do not include it in the calculation of sum
and average. Print the sum and average. (5 points)
Q6) Create a function that can count the number of digits in a positive integer. User will provide
that positive integer in the main function and the program will display the count. Write the full
code showing function calls from main (). (5 points)
Example: if n=5782, result will be 4.
Function Prototype: int count_digit (int n);
North South University
Department of Computer Science and Engineering
Course: -CSE115
Mid Term Exam, Fall 2020, Time: 1 Hour 30 Minutes
Please answer all the questions, Total Points: 50
Expected Output:
Enter number of patients and tests
2 4
Patient id: 1
Cost for 4 tests for patient ID :1
100 150 50 20
Total : TK320
You are OK . Good day.
Patient id: 2
Price for 4 tests for patient ID :2
100 500 600 1000
Total : TK 2200
You are very ill. Do not panic. Our doctors are here to help.
BEST OF LUCK
North South University
Department of Computer Science and Engineering
Course: -CSE115
Mid Term Exam, Fall 2020, Time: 1 Hour 30 Minutes
Please answer all the questions, Total Points: 50
() Functional call
[] Array element reference
Left to right
-> Indirect member selection
. Direct member selection
! Logical negation
~ Bitwise(1 's) complement
+ Unary plus
- Unary minus
++ Increment
Right to left
-- Decrement
& Dereference (Address)
* Pointer reference
sizeof Returns the size of an object
(type) Typecast (conversion)
* Multiply
/ Divide Left to right
% Remainder
+ Binary plus(Addition)
Left to right
- Binary minus(subtraction)
== Equal to
Left to right
!= Not equal to
= Simple assignment
*= Assign product
/= Assign quotient
%= Assign remainder
+= Assign sum
-= Assign difference Right to left
&= Assign bitwise AND
^= Assign bitwise XOR
|= Assign bitwise OR
<<= Assign left shift
>>= Assign right shift