This is what I have so far include include using namespace s
This is what I have so far:
#include <iostream>
#include<string>
using namespace std;
int main()
{
string Month[]= {\"January\", \"February\", \"March\", \"April\",
\"May\", \"June\", \"July\",\"August\", \"September\",
\"October\",\"November\", \"December\"};
int Days[]={31, 28, 31, 30,31, 30, 31, 31,30, 31, 30, 31};
for(int count=0; count<12; count++)
{
cout<<Month[count]<<\" has \"<<Days[count]<<\" days.\"<<endl;
}
system (\"pause\");
return 0;
}
Solution
#include <iostream>
#include<string>
using namespace std;
int main()
{
string Month[]= {\"January\", \"February\", \"March\", \"April\",
\"May\", \"June\", \"July\",\"August\", \"September\",
\"October\",\"November\", \"December\"};
int Days[]={31, 28, 31, 30,31, 30, 31, 31,30, 31, 30, 31};
for(int count=0; count<12; count++)
{
cout<<Month[count]<<\" has \"<<Days[count]<<\" days.\"<<endl;
}
//printing days in february in a leap year
cout<<Month[1]<<\" has \"<<Days[1]+1<<\" days in a leap year.\"<<endl;
int totaldays=0; //variable to store total days
//loop to calculate total days in a regular year
for(int count=0;count<12;count++){
totaldays=totaldays+Days[count];
}
//print days in a regular year
cout<<\"Days in the regular year : \"<<totaldays<<endl;
//print days in a leap year
cout<<\"Days in the leap year : \"<<totaldays+1<<endl;
// system (\"pause\");
return 0;
}
/******OUTPUT*******
January has 31 days.
February has 28 days.
March has 31 days.
April has 30 days.
May has 31 days.
June has 30 days.
July has 31 days.
August has 31 days.
September has 30 days.
October has 31 days.
November has 30 days.
December has 31 days.
February has 29 days in a leap year.
Days in the regular year : 365
Days in the leap year : 366
*******OUTPUT********/
/* Note:I have added the required changes with comments for the understaanding,Code has been tested on g++ compiler,please do ask in case of any doubt,Thanks.*/
![This is what I have so far: #include <iostream> #include<string> using namespace std; int main() { string Month[]= {\ This is what I have so far: #include <iostream> #include<string> using namespace std; int main() { string Month[]= {\](/WebImages/34/this-is-what-i-have-so-far-include-include-using-namespace-s-1101889-1761582378-0.webp)
![This is what I have so far: #include <iostream> #include<string> using namespace std; int main() { string Month[]= {\ This is what I have so far: #include <iostream> #include<string> using namespace std; int main() { string Month[]= {\](/WebImages/34/this-is-what-i-have-so-far-include-include-using-namespace-s-1101889-1761582378-1.webp)