| | |
requiring date validating program
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2009
Posts: 3
Reputation:
Solved Threads: 0
#include "stdafx.h"
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
struct date
{
int day;
int month;
int year;
};
struct date today,tomorrow;
int main()
{
const int days_month[12] ={31,28,31,30,31,30,31,31,30,31,30,31};
printf("enter today's day,month and year\n");
scanf("%d%d%d",&today.day,&today.month,&today.year);
if (today.day != days_month[today.month-1])
{
tomorrow.day = today.day + 1;
tomorrow.month = today.month;
tomorrow.year = today.year;
}
else
{
tomorrow.day = 1;
tomorrow.month = today.month + 1;
tomorrow.year = today.year;
}
if ((today.month==12)&&(days_month[today.month-1] == today.day))
{
tomorrow.month=1;
tomorrow.year=today.year+1;
}
else
{
tomorrow.year=today.year;
}
printf("Today's date is %d/%d/%d\n", today.day, today.month,
today.year);
printf("Tomorrow's date is %d/%d/%d\n", tomorrow.day,
tomorrow.month, tomorrow.year);
getch();
return 0;
}
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
struct date
{
int day;
int month;
int year;
};
struct date today,tomorrow;
int main()
{
const int days_month[12] ={31,28,31,30,31,30,31,31,30,31,30,31};
printf("enter today's day,month and year\n");
scanf("%d%d%d",&today.day,&today.month,&today.year);
if (today.day != days_month[today.month-1])
{
tomorrow.day = today.day + 1;
tomorrow.month = today.month;
tomorrow.year = today.year;
}
else
{
tomorrow.day = 1;
tomorrow.month = today.month + 1;
tomorrow.year = today.year;
}
if ((today.month==12)&&(days_month[today.month-1] == today.day))
{
tomorrow.month=1;
tomorrow.year=today.year+1;
}
else
{
tomorrow.year=today.year;
}
printf("Today's date is %d/%d/%d\n", today.day, today.month,
today.year);
printf("Tomorrow's date is %d/%d/%d\n", tomorrow.day,
tomorrow.month, tomorrow.year);
getch();
return 0;
}
![]() |
Similar Threads
- How to get the current date in JAVA (JSP)
- Using the time and date? (C++)
- resetting variable that is of type date to "00/00/0000" (Visual Basic 4 / 5 / 6)
- System Date Capturing (Java)
- Bug in getting the current date (C++)
- Capture system date? (C++)
- tomorrow date??? . (PHP)
- Countdown to a date (Visual Basic 4 / 5 / 6)
- Setting system date and time using c++ (C++)
Other Threads in the C++ Forum
- Previous Thread: how can i get this delete function working pls!!!
- Next Thread: Oops (c++)
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





