Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- int kab (int);
- struct date {
- int tgl, bln, thn;
- };
- main() {
- struct date today;
- struct date tomorrow;
- int bln[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
- puts("========== PERCOBAAN 6 PRAKTIKUM STRUCT 1 ==========\n");
- printf("Masukkan tanggal : "); scanf("%d", &today.tgl);
- printf("Masukkan bulan : "); scanf("%d", &today.bln);
- printf("Masukkan tahun : "); scanf("%d", &today.thn);
- if(kab(today.thn))
- bln[2] = 29;
- tomorrow.tgl = today.tgl+1;
- tomorrow.bln = today.bln;
- tomorrow.thn = today.thn;
- while(tomorrow.tgl > bln[tomorrow.bln]) {
- tomorrow.tgl -= bln[tomorrow.bln];
- tomorrow.bln += 1;
- if(tomorrow.bln > 12) {
- tomorrow.bln = 1;
- tomorrow.thn += 1;
- }
- }
- puts("----------------------------------------------------");
- printf("Today : \nTanggal : %d\n", today.tgl);
- printf("Bulan : %d\n", today.bln);
- printf("Tahun : %d\n\n", today.thn);
- printf("Tomorrow : \nTanggal : %d\n", tomorrow.tgl);
- printf("Bulan : %d\n", tomorrow.bln);
- printf("Tahun : %d\n", tomorrow.thn);
- getch();
- return 0;
- }
- int kab (int x) {
- int a;
- if(x % 400 == 0)
- a = 1;
- else if(x % 100 == 0)
- a = 0;
- else if(x % 4 == 0)
- a = 1;
- else
- a = 0;
- return (a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement