> I am unable to run the code please help me please tell me what I have to use to store months as a variable. I am new to the programming world it would be helpful if you will help me when I am compiling it. and it says "warning character constant too long for its type I had created a program to check how many days are in the given month so I take a value from the user and put it into m I had also tried taking the value of m as (character) but it's not working then check if it is Feb or other months if Feb then it will ask to enter the year(y) if it is not Feb then it will match the value of m within all condition and tell the month(m) "
#include<iostream>
using namespace std;
int main(){
char m;
int y;
cout<<"Plase Enter The month:- ";
cin>>m;
if (m=='january'||m=='march'||m=='april'||m=='may'||m=='june'||m=='july'||m=='august'||m=='september'||m=='december'||m=='october'||m=='november'||m=='jan'||m=='mar'||m=='apr'||m=='may'||m=='jun'||m=='jul'||m=='aug'||m=='sep'||m=='dec'||m=='oct'||m=='nov'||m=='JANUARY'||m=='MARCH'||m=='APRIL'||m=='MAY'||m=='JUNE'||m=='JULY'||m=='AUGUST'||m=='SEPTEMBER'||m=='OCTOBER'||m=='NOVEMBER'||m=='DECEMBER')
{
if (m=='jan'||m=='january'||m=='JANUARY')
{
cout<<"There Are 31";
}
else if (m=='march'||m=='mar'||m=='MARCH')
{
cout<<"There Are 31";
}
else if (m=='apr'||m=='april'||m=='APRIL')
{
cout<<"There Are 30";
}
else if (m=='may'||m=='MAY')
{
cout<<"There Are 31";
}
else if (m=='june'||m=='jun'||m=='JUNE')
{
cout<<"There Are 30";
}
else if (m=='jul'||m=='july'||m=='JULY')
{
cout<<"There Are 31";
}
else if (m=='aug'||m=='august'||m=='AUGUST')
{
cout<<"There Are 31";
}
else if (m=='sep'||m=='september'||m=='SEPTEMBER')
{
cout<<"There Are 30";
}
else if (m=='oct'||m=='october'||m=='OCTOBER')
{
cout<<"There Are 31";
}
else if (m=='nov'||m=='november'||m=='NOVEMBER')
{
cout<<"There Are 30";
}
else if (m=='dec'||m=='december'||m=='december')
{
cout<<"There Are 31";
}
}
else if(m=='feburary'||m=='feb'||m=='FEBURARY'){
cout<<"You Entered ";
cout<<m;
cout<<" which have more days in Leap year's ";
cout<<"So Please Enter The year:- ";
cin>>y;
if (y>=1752)
{
if ((y-1752)%4==0)
{
cout<<"There are 29 days";
}
else if((y-1752)%4!=0){
cout<<"There is 28 days";
}}
else{
cout<<"The First leap is started from 1752 so Please enter Number Greater than it";
}
}
else cout<<"------------------Please Enter A valid Month or Check Your Spelling--------------------";
return 0;
}
Aucun commentaire:
Enregistrer un commentaire