0% found this document useful (0 votes)
20 views2 pages

Summer 2024 - CS201 - 3

CS201 assignment no 3

Uploaded by

Bilal Mustafa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Summer 2024 - CS201 - 3

CS201 assignment no 3

Uploaded by

Bilal Mustafa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment No.

2 Total Marks: 20
Semester: Summer 2024 Due Date: 19th Sep, 2024
CS201 – Introduction to Programming Syllabus: All lectures
up to lecture 27.

Instructions
Please read the following instructions carefully before submitting the assignment solution:
It should be clear that your assignment will not get any credit/marks if:
o Assignments are submitted after the due date.
o The submitted assignment does not open or the file is corrupt.
o Assignment is copied (From internet/students).

Recommended Tools
 Dev C++
Topic Covered
 Loops
 If/else statements
 Functions
 Classes and Object
Assignment Submission Instructions
You must submit only “.cpp” file of your code on the assignments interface from your LMS
account.
Assignments submitted in any other format will not be accepted and will be scaled with zero
marks. No excuse will be accepted on submitting solution file in any other format.
For any query related to assignment, please contact [email protected].

Problem Statement – Step by Step:


You are required to create a program that will take your VU ID hard coded into a string variable
and perform the operations given below.
1. You will provide the hard-coded Student ID and save the ID in a string variable. You must
print the Student ID as shown in the output screenshot.
2. Create “Student” class which has a private string type data member stdID.
3. Create a setter function in Student class that will take student ID as an argument and store it
into stdID.
4. Create another function “Extract” or any other name of your choice. This function will use
data stored in stdID and perform the following functions.
a. Extracts the numerical digits from stdID and stores them in an integer variable,
the return type of the function should be integer. You must print the numerical
part of Student ID.
b. Use a loop to go through the numerical digits of Student ID and store the odd
digits in one variable and even digits in another variable. You must print the odd
digits and even digits.
c. Calculate and print the sum of odd digits.
d. Calculate and print the sum of even digits.
e. Calculate and return the sum of all digits (odd + even). Main function will print
the sum calling this function.

Output Results
o Print the following details:

1. The complete Student ID


2. The numerical part of the Student ID
3. The odd digits, extracted from the numerical part.
4. The even digits, extracted from the numerical part.
5. The sum of the odd digits.
6. The sum of the even digits.
7. The sum of all digits (odd + even)
Sample screenshot:

Note: In case of not using your own VU Student ID, you will be awarded zero mark

You might also like