100% found this document useful (1 vote)
590 views

CS-116 - Programming Fundamentals - End Semester Exam

This document contains instructions for an end semester examination for a Programming Fundamentals course. It provides details such as the course code, instructor, date and time of the exam, maximum marks, and instructions for submitting answers. The exam contains 5 questions, with the first 3 questions requiring handwritten or typed answers and the last 2 questions involving coding solutions. Students are instructed to follow general guidelines for online exams and to submit their answers in a single PDF file.

Uploaded by

ali
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
100% found this document useful (1 vote)
590 views

CS-116 - Programming Fundamentals - End Semester Exam

This document contains instructions for an end semester examination for a Programming Fundamentals course. It provides details such as the course code, instructor, date and time of the exam, maximum marks, and instructions for submitting answers. The exam contains 5 questions, with the first 3 questions requiring handwritten or typed answers and the last 2 questions involving coding solutions. Students are instructed to follow general guidelines for online exams and to submit their answers in a single PDF file.

Uploaded by

ali
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

End Semester Examinations: Spring 2020 Date: 23rd June 2020

Sir Syed University of Engineering & Technology


Faculty of Basic & Applied Sciences
Department of ____Information Technology___________

End Semester Examinations (Spring 2020)


Course Title with
CS-116T: Programming Fundamentals Program BSIT
Code
Instructor Abdul Khaliq Semester 1st
Start date & Time June 23, 2020 Submission Deadline June 23, 2020
at 10:30 AM at 04:30PM
Maximum Marks 50

IMPORTANT INSTRUCTIONS:

Read the following Instructions carefully:

● All Questions carries equal marks


● Q#1, Q#2 and Q#5 should be handwritten or typed on MS-Word.
● Q#3 and Q#4 should be solved on Visual Studio or any other software tool. Codes and
output screenshots of Q#3 & Q#4 must be converted to PDF format before submission.
● Those students who don’t have laptop or required software tools, are allowed to solve Q#3
and Q#4 on paper with proper comments wherever necessary.
● Finally, solutions of all five questions must be converted in a single PDF file format in
sequence. (Use any suitable Mobile Application for Scanning)
● For Diagrams, you can use paper and share a clear visible snapshot in the same Answer
Sheet.
● Arrange questions and their subsequent parts in sequence with page numbers on top.
● Make sure that your answers are not plagiarized or copied from any other sources. In case
of plagiarism, ZERO marks will be awarded.
● Provide relevant, original and conceptual answers, as this exam aims to test your ability to
examine, explain, modify or develop concepts discussed during the course.
● Recheck your answer before the submission on VLE to correct any content or language
related errors.
● You must upload your answers via the VLE platform ONLY.

You must follow general guideline for students before online examination and during
online examination which had already shared by email and WhatsApp.

This paper has a total of _06__ pages including this title page

SSUET Page1of6 FB&AS


End Semester Examinations: Spring 2020 Date: 23rd June 2020

Sir Syed University of Engineering & Technology


Faculty of Basic & Applied Sciences
Department of ____Information Technology___________

Q.1. (10)
Analyze and put down the values of variables a, b and c after the execution of each line. Show
step by step working for each statement.
Note: You have to write your own 2-digit roll number against RollNumber wherever mentioned.

int main() a b c
{ int a=0;int b=1; int c=2; int d=3;
a = b + c * d << RollNumber && 8;
a = a && RollNumber != 3;
a = a == b || a == c && RollNumber < 5;
c = x != 0;
a = -1 + RollNumber-- - 5 + ++c;
a = b == c++;
a = b = c = 0;
c = 7 - -5 + 23 / RollNumber != 45 && b > 7;
a= a-b/c;
c = 7 - -5 + 23 / 34 != RollNumber && b > 7 + ++a / 1 ||sizeof(int);
return 0;}

Q.2. (10)
Dry run the following lines of C++ code. Each statement is performed independently and not
connected with previous.
Note: You have to assign your own roll number to variable b given below before solving.

Initially a = 2, b = RollNumber, c =10, d =5 ;


I. e = (a + b) * c / d;
cout << "Value of (a + b) * c / d is :" << e << endl ;
II. e = ((a + b) * c) / d;
cout << "Value of ((a + b) * c) / d is :" << e << endl ;
III. e = (a + b) * (c / d);
cout << "Value of (a + b) * (c / d) is :" << e << endl ;
IV. e = a + (b * c) / d;
cout << "Value of a + (b * c) / d is :" << e << endl ;

SSUET Page2of6 FB&AS


End Semester Examinations: Spring 2020 Date: 23rd June 2020

Sir Syed University of Engineering & Technology


Faculty of Basic & Applied Sciences
Department of ____Information Technology___________

V. e = a + (b - c) / d * c + a; // 20 + (150/5)
cout << "Value of a + (b - c) / d * c + a is :" << e << endl ;

VI. cout << "Value of b++ and ++b is: “ << b++ << ++b;

VII. cout << "Value of ++b + a++ is: “ << ++b + a++;

VIII. cout << "Value of d++ % b++ is: “ << d++ % b++;

IX. cout << "Value of b++ << ++c << ++b << c++ is: “ << c++ << ++c << ++b <<
b++;

X. if ((c = (d==9 || b==4)))


cout<<<< "Value of c is: “<<c;

Q.3. (10)

A.
Number guessing games are quite interesting. Design a program for a guessing game,
which allows N number of tries to a user for guessing a randomly generated number
where N equals the integer value calculated by formula given below. At each wrong try,
the program informs the user whether the input number is either larger or smaller than
guess_num. The program prints “Congrats! You won.” if the user guessed the number
correctly. If user can’t guess correct number in N tries, then program should print
“Unfortunately You lost”.
N = ( (RollNumber+20) % 5 ) + 4
Note: Students are required to provide their own Roll Number in above formula to
calculate the value of N.

SSUET Page3of6 FB&AS


End Semester Examinations: Spring 2020 Date: 23rd June 2020

Sir Syed University of Engineering & Technology


Faculty of Basic & Applied Sciences
Department of ____Information Technology___________

B.
Draw the flowchart for problem statement of part A. Flowchart must be drawn on plain
paper.

Q.4. (10)
A.
Suppose there are two variable length character arrays containing first name and last name of
student. Both array values are to be entered by user at run time. Write a program to merge
and sort both of the arrays in a third character array in ascending order based on ASCII
values of each character and then display the final output and total length of third array on
screen (don’t count spaces in total length). You can use bubble sort algorithm for sorting
purpose.
Note: (ASCII values of Capital letters A-Z are 65-90 and of small letters a-z are 97-122).
Use only Capital letters or only small letters at one time as shown in sample runs below.

Sample Run 1
Enter First Name: ALI
Enter First Name: NADEEM
After merging and sorting: A A D E E I L M N
Total Length of final Array: 9

Sample Run 2
Enter First Name: amir
Enter First Name: khan
After merging and sorting: a a h i k m n r
Total Length of final Array: 8

B.
Write down the step by step algorithm for problem statement of part A.
Note: Solve this part on plain paper.

SSUET Page4of6 FB&AS


End Semester Examinations: Spring 2020 Date: 23rd June 2020

Sir Syed University of Engineering & Technology


Faculty of Basic & Applied Sciences
Department of ____Information Technology___________

Q.5. Specify the logical and/or syntax errors in following chunks of code and re-write the
correct version of code. Justify your answer with proper reasoning for each statement.
Note: There might be more than one errors and no error at all. (10)
A.
#include<iostream.h>
void main()
{
int i= RollNumber, j=5; // Assign your own roll number to variable i
int modResult=0;
int divResult=0;
modResult = i%j;
cout<<modResult<<" ";
divResult = i/modResult;
cout<<divResult;
}

B.
int main()
{
int i = 0;
for(i = 0; i < 3; i++);
{
cout<<"loop ";
continue;
}
getchar();
return 0;
}

C.
int main()
{
int x=3, y=4, z=5;
for(x=0;x<z;x++)
{
for(y=0;y<=x;y++)
{
if(a=='Z')
break;

SSUET Page5of6 FB&AS


End Semester Examinations: Spring 2020 Date: 23rd June 2020

Sir Syed University of Engineering & Technology


Faculty of Basic & Applied Sciences
Department of ____Information Technology___________
cout<<a;

a++;
}
cout<<endl;
}
}

D.
int x = 2;
switch(x)
{
case 2:
cout << "two" << endl;
case 3:
cout << "three" << endl;
}

E.
#include<iostream>
int main()
{
int i=1;
while()
{
cout<<"i++”<<endl;
if(i>RollNumber) // Put 1st digit of your Roll No in if condition
break;
}
return 0;
}

SSUET Page6of6 FB&AS

You might also like