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

M Usman OOP

C++ program

Uploaded by

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

M Usman OOP

C++ program

Uploaded by

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

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;
}

You might also like