Answer to Question #16935 in C++ for Bishoy fam

Question #16935
Write an algorithm that determines the day number ( 1 to 366) in a year for a date that is provided as input data. For example, 1/1/1994 is the day number 1, while, 31/12/1994 is the day number 366 because 1994 is a leap year.

Hint: A year is a leap year if it is devisable by 4 except any year that is divisible by 100 is a leap year if it is divisible by 400.
( sorry i want it in flowchart and pseudo-code)
1
Expert's answer
2012-10-26T10:38:16-0400
#include<iostream>
using namespace std;

char msg[200], inv[200];
int y, m, d, n=0, i;

void main(){
cout<<"enter the year: ";
cin>>y;
cout<<"enter the month: ";
cin>>m;
cout<<"enter the day: ";
cin>>d;
n += d;
for (i=1; i<m; i++){
& if (i==1) n+=31;
& if ((y%4==0)&&(i==2)) n+=29;
& else if (i==2) n+=28;
& if (i==3) n+=31;
& if (i==4) n+=30;
& if (i==5) n+=31;
& if (i==6) n+=30;
& if (i==7) n+=31;
& if (i==8) n+=31;
& if (i==9) n+=30;
& if (i==10) n+=31;
& if (i==11) n+=30;
}
cout<<"the day number is "<<n<<".\n";
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS