Girilen tarihteki günün adını veren program

İf Then Else İcice Örenği

#include
main ( )
{
int gun, ay, yıl ;
long gt ;
printf(“Tarihi gir”) ; scanf ( “%d %d %d “,&gun)

/* oncekı yıllardakı gun sayısını hesapla */

gt=( yıl*1)*365 + yıl/4;

/* bu yildaki aylardaki gunleri ekle */

if (ay==2)
gt = gt + 31 ;
else if (ay ==3)
gt = gt + 31 + 28 ;
else if (ay ==4)
gt = gt + 31 + 28 +31;
else if (ay ==5)
gt = gt + 31 + 28 +31+ 30 ;
else if (ay ==6)
gt = gt + 31 + 28 +31+ 30 +31;
else if (ay ==7)
gt = gt + 31 + 28 +31+ 30 +31+ 30 ;
else if (ay ==8)
gt = gt + 31 + 28 +31+ 30 +31+ 30 + 31 ;
else if (ay ==9)
gt = gt + 31 + 28 +31+ 30 +31+ 30 + 31+30 ;
else if (ay ==10)
gt = gt + 31 + 28 +31+ 30 +31+ 30 + 31+30 + 31;
else if (ay ==11)
gt = gt + 31 + 28 +31+ 30 +31+ 30 + 31+30 + 31+ 30 ;
else if (ay ==12)
gt = gt + 31 + 28 +31+ 30 +31+ 30 + 31+30 + 31+ 30 +31;

/*Bu ayı ekle */
gt = gt+ gun;
if(yıl%4==0 && ay>2),
gt =gt+1;
gt=gt %7,
if(gt==1)
printf(“Pazar”);
else if(gt==2)
printf(“Pazartesi”);
else if(gt==3)
printf(“Salı”);
else if(gt==4)
printf(“Carsamba”);
else if(gt==5)
printf(“Persembe”);
else if(gt==6)
printf(“Cuma”);
else if(gt==7)
printf(“Cumartesi”);
}

0 yorum: