Assignment No.
1 Total Marks: 20
Semester: Fall 2022 Due Date: Dec 5,
CS201P – Introduction to Programming Practical 2022
Instructions
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:
o Assignment is submitted after due date.
o Submitted assignment does not open or file is corrupt.
o Assignment is copied (From internet/students).
Software allowed to develop Assignment
- Dev C++
Objectives:
In this assignment, the students will learn:
How to use if statement and loops.
Assignment Submission Instructions
You are required to submit only .cpp file on the assignments interface of CS201P at VU-LMS.
Assignment submitted in any other format (like doc, docx, jpg, png, giff, etc)
will not be accepted and will be graded zero marks. So, check your solution file
format before submission.
For any query related to assignment, please contact [email protected]
Copyright © Virtual University of Pakistan
Problem Statement:
Sometimes in programming, there may be a need to run a block of code repeatedly. In general, the programming
statements are executed in order. Different control structures offered by programming languages allow for more
complex execution paths. A loop statement allows us to execute a statement or collection of statements multiple
times. Conditional branching statement (if-else), on the other hand, controls the flow of execution of statements
based on some condition. If the given condition is true, the code inside IF block is executed, otherwise Else block
code is executed.
Now keeping in mind, the above discussed concepts,write a C++ program using FOR loop and If-Else statement
that performs the following tasks:
1. Print your VU Id.
2. Add first and last numeric digit of VU Id, and store the result in variable “sum”.
3. Display the result of sum on screen.
4. If sum is greater than 7 then print the “Welcome to VU”. Number of iterations of FOR loop should be
equal to the sum.
5. If sum is less than 7 then print the “Welcome to CS201P”. Number of iterations of FOR loop should be
equal to the sum.
For example, suppose the student id is BC123456781. Then by adding first and last numeric digit of VU Id, we get
the value of 2. In this case, program should print “Welcome to CS201P” for 2 times using FOR loop and vice
versa.
Sample Screenshots:
For the given supposed VU Id (BC123456781), following will be the output of the program.
NOTE: Student’s id is a supposed value (not real) in above example. You will print your own VU Id otherwise
you will get zero marks.
Wish you Good Luck!
Lectures Covered: This assignment covers Labs # 1-3.
Deadline: The deadline to submit your assignment solution is Dec 5, 2022 .Your assignment must be submitted
within the due date through VU-LMS. No assignment will be accepted through email after the due date.
Copyright © Virtual University of Pakistan