Monday 24 October 2011

Program C++ Looking for a leap year

Program  C++ Looking for a leap year. It's a leap year can you find in C + +? Leap year is the year is divisible by 4 or 400 but not divisible by 100. Well, of course, the above explanation, we know the algorithm search program making the leap year.

Use if statements to look for it. If it is divisible by 4, or is divisible by 400 and not divisible by 100, then the leap year. Now we will look for how many leap years between two years that entered. Use a statement for or looping for this one.

#include <iostream.h>
#include <conio.h>

int main()
{
 int awal, akhir, tahun;
 clrscr();

 cout<<"Masukkan Tahun Awal : ";
 cin>>awal;
 cout<<"Masukkan Tahun Akhir : ";
 cin>>akhir;
 clrscr();

 cout<<"Tahun Kabisat Antara "<<awal<<" dan "<<akhir<<" adalah : ";
 cout<<endl<<endl;
 for(tahun=awal; tahun<=akhir; tahun++)
 {
  if((tahun%4==0)||(tahun%400==0)&&(tahun%100!=0))
  cout<<tahun<<endl;
  else
  cout<<"";
 }
 getch();
}

No comments:

Post a Comment