0% found this document useful (0 votes)
47 views

North South University: Department of Computer Science and Engineering

The document provides instructions for a midterm exam in CSE115 at North South University. It contains 7 questions worth a total of 50 points. The questions cover topics like software categories, data types, operators precedence, writing C programs to solve problems related to credit limits, calculating averages, counting digits, and medical tests. Students are instructed to show working, comment code, and upload their work within the time limit. Plagiarism will be strictly handled.

Uploaded by

Sami Islam
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)
47 views

North South University: Department of Computer Science and Engineering

The document provides instructions for a midterm exam in CSE115 at North South University. It contains 7 questions worth a total of 50 points. The questions cover topics like software categories, data types, operators precedence, writing C programs to solve problems related to credit limits, calculating averages, counting digits, and medical tests. Students are instructed to show working, comment code, and upload their work within the time limit. Plagiarism will be strictly handled.

Uploaded by

Sami Islam
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/ 6

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

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.

Q1) Short Questions and Answers: (10 points)


a) Name the main categories of software. Give examples in each case. (2)
b) Write about the 3 categories of computer languages with example. (3)
c) Convert from Hexadecimal to Octal. (C4E.5B) 16 = (?)8 . Show your work (3)
d) Find out which variable names are invalid and why? (2)
99Hello, iteaM, Switch, _avg_value , double, ,avg_value

Q2 Find the output:(5 points)


Q2a ) Find the output (show your work) (3points)
i) ii)
#include <stdio.h> #include<stdio.h>
void main(){ void main (){
int a = -6; int a=11,b=3,d=5;
printf("%d", ++a*4+1); float c,e=2;
printf("\n%d", a+3); c=7/2;
} d=5*0.5;
printf("%d \n",a/b);
printf("%f \n" ,a/e);
printf("%f \n",c);
printf("%d \n",d);
}

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

Q7) Write a code in C for the following scenario: (10 points)


Consider a hospital scenario where “z” number of patients wants to undertake some medical
examination. Each patient registers for “t” number of tests and the test to be conducted is
determined by qualified doctors after listening symptoms. Each test cost is different and hence
each test is identified by the price paid. Write a program to read the cost for the tests undertaken
by each patients and print the total bill paid by each patient. Then the program should decide if
the patient is very ill, moderately ill and ok (Very ill: Pay Bill Tk2000 and above, Moderately
ill: Pay Bill between Tkl999 and Tk500, ok: Pay Bill below Tk500)

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

Operators Precedence & Associativity Table

Operator Meaning of operator Associativity

() 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)

<< Left shift


Left to right
>> Right shift

< Less than Left to right


<= Less than or equal
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

> Greater than


>= Greater than or equal

== Equal to
Left to right
!= Not equal to

& Bitwise AND Left to right

^ Bitwise exclusive OR Left to right

| Bitwise OR Left to right

&& Logical AND Left to right

|| Logical OR Left to right

?: Conditional Operator Right to left

= 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

, Separator of expressions Left to right


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

You might also like