100% found this document useful (1 vote)
573 views2 pages

GC University Lahore Department of Computer Science Mid Term Exam - 2021

The document provides details for a midterm exam for a Visual Programming course, including: 1) The exam allows 1.5 hours and is worth a total of 30 marks. 2) It contains 4 questions and students must attempt all questions. 3) The first question involves writing a program to check if a given matrix is an identity matrix. The second asks students to write a C# program using classes and multiple inheritance to check angles and factorials. 4) The third question involves function execution sequence and output for a given code sample. 5) The fourth question asks students to write a C# program using classes that prompts for milk production input and outputs cartons needed, production

Uploaded by

Ahsin Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
573 views2 pages

GC University Lahore Department of Computer Science Mid Term Exam - 2021

The document provides details for a midterm exam for a Visual Programming course, including: 1) The exam allows 1.5 hours and is worth a total of 30 marks. 2) It contains 4 questions and students must attempt all questions. 3) The first question involves writing a program to check if a given matrix is an identity matrix. The second asks students to write a C# program using classes and multiple inheritance to check angles and factorials. 4) The third question involves function execution sequence and output for a given code sample. 5) The fourth question asks students to write a C# program using classes that prompts for milk production input and outputs cartons needed, production

Uploaded by

Ahsin Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

GC University Lahore

Department of Computer Science


MID TERM EXAM - 2021
Program: BS (CS)
Course: Visual Programming
Course Code: CS-2201
Allowed Time = 1.5 hrs

Total Marks = 30
Note:
1. Cutting will be considered as wrong answer.
2. This paper is open book and open Internet.
3. Paper should be attempted in handwritten form and submit it in pdf format. Paper
attempted in soft form will not be accepted.
4. Attempt all Four Questions.
5. Paper must be submitted through email on asmakanwal@[Link] till 11:15 am on
8-4-2021.
6. Make sure you have attached your in email before submission. No Re-submission will be
allowed after 11:15 am.
7. Though email submission in subject line clearly mention your name, Roll number and
section.
8. Paper is self-explanatory. No query will be entertained.
9. Write your name, roll number and section on answer sheet. Un-named paper will not be
accepted.

Question 1: Write a program using abstract class to check whether a Given Matrix is an Identity Matrix.
(8- Marks)

Question 2: Write a C# program by using classes  in which user enter the three angles a1, a2, and a3, and
then program will check that its valid triangle or not. If it’s valid triangle, then find the factorial of a1
with while loop, and find that a2 is a palindrome number or not.  If a2 is palindrome, then find the
factorial of a2. You must use the concepts of multiple inheritance in the program (10-
Marks)

Question 3: Write the sequence of execution of function.


(a) (2- Marks)

class base class Program


{ {
public void f1() {} static void Main(string[] args)
public virtual void f2() {} {
public virtual void f3() {} baseclass b = new derived();
} b.f1 ();
class derived :base b.f2 ();
{ b.f3 ();
new public void f1() {} }
public override void f2() {} }
public new void f3() {}
}

(b) What will be the output of given code: (2- Marks)


try
{
int []a = {1, 2, 3, 4, 5};
for (int i = 0; i < 7; ++i)
[Link](a[i]);
}
catch(IndexOutOfRangeException e)
{
[Link]("0");
}
[Link]();

Question 4: A milk carton can hold 3.78 liters of milk. Each morning, a dairy farm ships cartons of milk
to a local grocery store. The cost of producing one liter of milk is $0.38 and the profit of each carton of
milk is $0.27. Write a program in c# using classes that does the following: (8- Marks)

1. Prompt the user to enter the total amount of milk produced in the morning

2. Outputs the number of milk cartons needed to hold milk

3. Output the cost of producing milk

4. Outputs the profit for producing milk

You might also like