BİLİŞİM - BİLGİSAYAR - EĞİTİM
  Bir Tarihteki Günü Bulma
 

Girilen tarihteki günün adını veren programı yazınız.

#include <studio.h>
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”);
return 0;
/*www.bilisim-egitim.tr.gg*/
}
 
 
  Bugün 169 ziyaretçi (258 klik) www.bilisim-egitim.tr.gg  
 
Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol