Name: M Usman
Roll No: F23-BS-BBIT-5025
COURSE: Object Oriented Programming
Program 7.4
Write a program that inputs current day and month from the user. It
then calculates and displays the total number of days in current year till
the entered date.
#include <iostream>
using namespace std;
int main() {
int day, month, total = 0;
int days_per_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// Input the month number
cout << "Enter the month number (1-12): ";
cin >> month;
// Input the day number
cout << "Enter the day number: ";
cin >> day;
// Calculate total days up to the given date
for (int x = 0; x < month - 1; x++) {
total += days_per_month[x];
}
total += day;
// Output the result
cout << "The number of days in this year till date = " << total << endl;
return 0;
}