Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Homework HelpRSS Feeds

Program that takes short date from a user and displays long date

Posted By: Easy Tutor     Category: C++ Programming     Views: 2677

Write a program that takes short date from a user and displays long date in format 1st June 2000

Code for Program that takes short date from a user and displays long date in C++ Programming

#include<iostream.h> 

#include<conio.h>

void main()

{

shortint month,day;

int year;

clrscr();

cout<<"\nEnter Day of the Month:-";

cin>>day;

cout<<"\nEnter Month in Two Digit:-";

cin>>month;

cout<<"\nEnter Year in Four Digit:-";

cin>>year;

clrscr();

////VALIDATION FOR ENTERING ILLEGAL DAYS////if(month==2)

{

if(year%4==0) 

{

if(day>29 || day<=0)

{

cout<<"Entered Date is Illegal";

goto end;

}

}

else

{

if(day>28 || day<=0)

{

cout<<"Entered Date is Illegal";

goto end;

}

}

}

elseif(month==1||month==3||month==5||month==7||month==8||month==10||month==12)

{

if(day>31 || day<=0)

{

cout<<"Entered Date is Illegal";

goto end;

}

}

elseif(month==4||month==6||month==9||month==11)

{

if(day>30 || day<=0)

{

cout<<"Entered Date is Illegal";

goto end;

}

}

////VALIDATION FOR ENTERING ILLEGAL MONTH////if(month>12 || month<1)

{

cout<<"Entered Date is Illegal";

goto end;

}

////VALIDATION FOR YEAR////if(year<1000 ||year >=2100)

{

cout<<"Entered Date is Illegal ";

goto end;

}

//FOR DAYswitch(day)

{

case 1 :

case 21 :

case 31 :cout<<day<<"st ";

break;

case 2 :

case 22 :

cout<<day<<"nd ";

break;

case 3 :

case 23 :

cout<<day<<"rd ";

break;

default :

cout<<day<< "th ";

break;

}

//FOR MONTHswitch(month)

{

case 1:cout<<"January ";

break;

case 2:cout<<"February ";

break;

case 3:cout<<"March ";

break;

case 4:cout<<"April ";

break;

case 5:cout<<"May ";

break;

case 6:cout<<"June ";

break;

case 7:cout<<"July "; 

break;

case 8:cout<<"August ";

break;

case 9:cout<<"September ";

break;

case 10:cout<<"October ";

break;

case 11:cout<<"November ";

break;

case 12:cout<<"December ";

break;

}

//FOR YEAR

cout<<year;

end:

getch();

}

     
  
Share: 



Easy Tutor
Easy Tutor author of Program that takes short date from a user and displays long date is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!