Sample – Program to find the total days in the year till date.

by Nideesh C on February 8, 2011 · 1 comment

in C++




#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();
int day,month,total;
int days_per_month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
cout << “Enter the month : ” << endl;
cin>>month;
cout << “Enter the day : ” << endl;
cin>>day;
total=day;
for(int x=0;x<month-1;x++)
total+=days_per_month[x];
cout << “The number of days in this year till date = ” << total << endl;
getch();
}

This program takes in the current day and month as a screen input from the user.
It then calculates the total number of days in the current year till date and outputs it using the ‘cout’ command.

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. Sample – Program to convert days into years and weeks.
  2. Sample – Program to enter an integer and print its total value based on the formula ‘x – 1/3!x3 + 1/5!x5 – 1/7!x7 + 1/9!x9′.
  3. Sample – Program to find the roots of a quadratic equation.
  4. Sample – Program to enter a string and find its length.
  5. Sample – Program to enter the unit reading and output the customer’s telephone bill.

{ 1 comment… read it below or add one }

1 Robin February 23, 2011 at 7:36 am

Sample – Program to find the total days in the year till date. — Good article

Reply

Leave a Comment

Previous post:

Next post: