Name: Deab Sina
Major: D4 TMD ITB Batch6
Video:
Coding:
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
struct date // We declare struct variable that have content date, month, year
{
int date;
int month;
int year;
};
struct date now, tomorrow;
int tdate[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // element of array
printf("Insert Today Date In This Format : dd mm yyyy\n");
scanf_s("%d %d %d", &now.date, &now.month, &now.year);
if(now.date < tdate[now.month-1])
{
tomorrow.date = now.date +1;
tomorrow.month = now.month;
tomorrow.year = now.year;
}
else if(now.month == 12)
{
tomorrow.date = 1;
tomorrow.month = 1;
tomorrow.year = now.year + 1;
}
else
{
tomorrow.date = 1;
tomorrow.month = now.month + 1;
tomorrow.year = now.year;
}
printf("Tomorrow is date %d month %d year %d\n", tomorrow.date, tomorrow.month, tomorrow.year);
system("pause");
}
#include <stdio.h>
int main(void)
{
struct date // We declare struct variable that have content date, month, year
{
int date;
int month;
int year;
};
struct date now, tomorrow;
int tdate[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // element of array
printf("Insert Today Date In This Format : dd mm yyyy\n");
scanf_s("%d %d %d", &now.date, &now.month, &now.year);
if(now.date < tdate[now.month-1])
{
tomorrow.date = now.date +1;
tomorrow.month = now.month;
tomorrow.year = now.year;
}
else if(now.month == 12)
{
tomorrow.date = 1;
tomorrow.month = 1;
tomorrow.year = now.year + 1;
}
else
{
tomorrow.date = 1;
tomorrow.month = now.month + 1;
tomorrow.year = now.year;
}
printf("Tomorrow is date %d month %d year %d\n", tomorrow.date, tomorrow.month, tomorrow.year);
system("pause");
}
Link:
Thanks,
No comments:
Post a Comment