You are on page 1of 3

COMSATS University Islamabad

Department of Electrical & Computer Engineering


CSC241 Object Oriented Programming
Assignment No.: 01
[CLO-1 (C1): PLO-1]
Program: BEE-3(A) Total Marks: 100
Semester: Fall 2023 Post Date: 26th Sep. 2023
Instructor: Dr. Riaz Hussain T.A.:
Due Date: Wednesday, 4th Oct. 2023

Note: See the method for submission at the end.

I know you can find tons of implementations available on the internet; even at the end of the shared url.
I request you to try these problems yourself. Take a small step at a time and gradually build. If you are
stuck at any point/error; think yourself, take a small break, discuss it with someone (may be your
instructor) and then again get back to the problem independently to get pass the hurdle. Spend some
time and debug; I also know that you can do it and you will.

Question No. 1: [10]


Using C++ control structure write a program that reveres the order of digits of any given unsigned
integer number entered by the user. For example, if the user enters 987 as an input the output is 789.
(Review of basic programming concepts: Control Structures). In your submitted code write comment
at the end to indicate the difference in code as compared to what you did in CSC141ICP using C
programming.

Sample Output:
Enter any number: 6329
Reverse of number 6329 is 9236

Question No. 2: [40]


Write a C++ program that gives the following menu options:

1 Accept elements of an array


2 Display elements of an array
3 Sort the array in ascending order using the insertion sort method
4 Exit

Implement using C++ functions for all options. The functions should have two parameters i.e., name of
the array and number of elements in the array. You must declare the functions in the header file and
defined in the source file. (Review of basic programming concepts: Functions, Arrays).

To understand the “insertion sort” you can google it or learn from the following URL:
https://www.geeksforgeeks.org/insertion-sort/

Page 1 of 3 : Assignment-1 BEE-3A: Fall 2023: CSC241OOP Dr. Riaz Hussain


Sample Output:

Enter Size of Array 5

MENU
1. Accept elements of array
2. Display elements of array
3. Sort the array using insertion sort method
4. Exit

Enter your choice 1-6 :1


Enter number of elements you want to insert 5
Enter element 1: 13
Enter element 2: 69
Enter element 3: 30
Enter element 4: 51
Enter element 5: 20

MENU
1. Accept elements of array
2. Display elements of array
3. Sort the array using insertion sort method
4. Exit

Enter your choice 1-6 :2


The elements of the array are:
13 69 30 51 20

MENU
1. Accept elements of array
2. Display elements of array
3. Sort the array using insertion sort method
4. Exit

Enter your choice 1-6 :3


The sorted elements of the array are:
13 20 30 51 69

MENU
1. Accept elements of array
2. Display elements of array
3. Sort the array using insertion sort method
4. Exit

Enter your choice 1-6 :4

Page 2 of 3 : Assignment-1 BEE-3A: Fall 2023: CSC241OOP Dr. Riaz Hussain


Good Bye

In your submitted code write comment at the end to indicate the difference in code as compared to what
you did in CSC141ICP using C programming.

Question No. 3: [10]


Describe how does cout display the output on the screen and how does cin stores the value in the input
variable.

Question No. 4: [10 + 30]


a) Discuss the programming paradigm of OOP.
b) Elaborate the concepts of object, class, encapsulation, inheritance, polymorphism and
abstraction.

To submit your work,

Join the class: https://onlinegdb.com/classroom/invite/Bf1C1Zics1

Create a folder AssignmentNo-1

For each programming question create a project with appropriate name (preferably having question
number) within the folder (If needed can create subfolder for each programming question.) and submit.

In the class, you will submit the hard copy with the cover page and URLs of all the programming
questions and also any handwritten work required for assignment completion (e.g., Question No. 3 and
4 of this assignment).

In MS Teams, before the beginning of the class on due date, upload the soft copy with the scanned
pages of the handwritten work, if any, included. And Don’t forget to submit the assignment in MS
Teams. Note the links should be clickable, so that I can directly access your code.

Page 3 of 3 : Assignment-1 BEE-3A: Fall 2023: CSC241OOP Dr. Riaz Hussain

You might also like