PROGRAM C++ UNTUK MENGHITUNG UMUR
Halaman 1 dari 1
PROGRAM C++ UNTUK MENGHITUNG UMUR
LANGSUNG TES SENDIRI AJA BRAY...
OUTPUTNYA :
- SKRIPNYA LUMAYAN PANJANG BRAY:
#include <conio.h>
#include <iostream.h>
void main()
{
int d1,m1,y1,d2,m2,y2,y,bulan1,
bulan2,tgl1,tgl2;
cout<<"Masukkan Data Sekarang"<<endl<<endl;
cout<<"Tanggal : ";cin>>d1;
cout<<"Bulan : ";cin>>m1;
cout<<"Tahun : ";cin>>y1;
cout<<endl;
cout<<"Masukkan Data Kelahiran Anda"<<endl<<endl;
cout<<"Tanggal : ";cin>>d2;
cout<<"Bulan : ";cin>>m2;
cout<<"Tahun : ";cin>>y2;
cout<<endl;
y=y1-y2;
bulan1=m1-m2;
bulan2=m2-m1;
tgl1=d1-d2;
tgl2=d2-d1;
{
if((y1>y2)&&(d1>=d2)&&(m1>=m2))
{
cout<<"Umur anda tertanggal "<<d1<<"-"<<m1<<"-"<<y1<<" dari "<<d2<<"-"<<m2<<"-"<<y2<<" adalah "<<y<<" tahun "<<bulan1<< " bulan "<<tgl1<< " hari "<<endl;
}
else if((y1>y2)&&(d2>=d1)&&(m2>=m1))
{
cout<<"Umur anda tertanggal "<<d1<<"-"<<m1<<"-"<<y1<<" dari "<<d2<<"-"<<m2<<"-"<<y2<<" adalah "<<y<< " tahun "<<bulan2<< " bulan " <<tgl2<< " hari "<<endl;
}
else if((y1>y2)&&(d1>=d2)&&(m2>=m1))
{
cout<<"Umur anda tertanggal "<<d1<<"-"<<m1<<"-"<<y1<<" dari "<<d2<<"-"<<m2<<"-"<<y2<<" adalah "<<y<<" tahun "<<bulan2<<" bulan "<<tgl1<<" hari "<<endl;
}
else if((y1>y2)&&(d2>=d1)&&(m1>=m2))
{
cout<<"Umur anda tertanggal "<<d1<<"-"<<m1<<"-"<<y1<<" dari "<<d2<<"-"<<m2<<"-"<<y2<<" adalah "<<y<<" tahun "<<bulan1<<" bulan "<<tgl2<<" hari "<<endl;
}
else
{
cout<<"Data Yang Anda Masukkan Tidak Valid"<<endl;
}
}
getch();
}
OUTPUTNYA :
- Spoiler:
Similar topics
» MASUKAN UNTUK SEORANG ADMIN
» PROGRAM C++ DERET BILANGAN GANJIL
» PROGRAM C++ DERET BILANGAN PRIMA
» MEMBUAT PROGRAM KLASIFIKASI NILAI PADA C++
» PROGRAM CEK BILANGAN PRIMA
» PROGRAM C++ DERET BILANGAN GANJIL
» PROGRAM C++ DERET BILANGAN PRIMA
» MEMBUAT PROGRAM KLASIFIKASI NILAI PADA C++
» PROGRAM CEK BILANGAN PRIMA
Halaman 1 dari 1
Permissions in this forum:
Anda tidak dapat menjawab topik
|
|