| | |
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 |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





