Fall 2024 - CS201 - 1
Fall 2024 - CS201 - 1
1 Total Marks: 20
th
Semester: Fall 2024 Due Date: 7 Nov, 2024
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
Assignment is submitted after the due date.
o
Submitted assignments do not open or the file is corrupt.
o
Assignment is copied (From internet/students).
Recommended Tools
● Dev C++
Topic Covered
● Loops
● Switch statements
● If/else statements
You must submit only the ".cpp” file of your code on the assignments interface from your LMS account.
An assignment submitted in any other format will not be accepted and will be scaled with zero marks. No excuse will be accepted on submitting a solution file in any
other format.
Problem Statement:
Write a program that outputs your name and ID, checks if a year (derived by dropping the last two digits from right and then extract the next four digits from the
numeric part of the studentID as explained below in step-by-step procedure) is a leap year or not, and then displays how many days there are in the month (take input
from user).
Note: If the year is divisible by 4 and not divisible by 100 or divisible by 400, print that it is a leap year; otherwise, print that it is not a leap year.
1.
Name and ID Output:
o The program should begin by outputting the student's name and VUID. Make sure the name and VUID are displayed at the very beginning of the
output.
2.
Leap Year Check:
o Instead of prompting the user for input, drop the last two digits from right and then extract the next four digits from the numeric part of the studentID
1. For VUID bc123450000, 4500 will be the year. You will drop the last two digits in the red and will take 4500 as year.
2. For VUID bc231201978, 2019 will be the year. You will drop the last two digits in the red and will take 2019 as year
3. For VUID bc223489124, 4891 will be the year. You will drop the last two digits in the red and will take 4891 as year
3.
Month Selection and Days Calculation:
o Take input from the user and determine the number of days, if month is invalid (i-e: not between 1 and 12) take appropriate action using if/else
statement.
o Use switch statements to determine how many days there are in that month. February should be handled differently for leap years (29 days) and non-
Note: Remember that if you have not used your name and student id in the program your marks will be deducted.
Sample Output:1
Sample Output:2
Lectures Covered: Lecture # 1 - 8
th
Due Date: 7 Nov, 2024