Selasa, 30 Juni 2015

C++ Program Jam Digital (tanpa CLASS )

Program Jam Digital Bahasa C++ ( tanpa CLASS )

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <windows.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char *argv[]) {
int jam, menit, detik;
 //deklarasi objek yang memanfaatkan class dan struct yang ada di library time.h
       time_t rawtime;
    tm * timeinfo;
 //proses pengambilan data waktu sistem
       time ( &rawtime );
timeinfo = localtime ( &rawtime );
//proses pemindahan data waktu sesuai dengan format ke dalam variabel
       jam=timeinfo->tm_hour;     //format untuk jam
       menit=timeinfo->tm_min;    //format untuk menit
       detik=timeinfo->tm_sec;    //format untuk detik
while (true){
system ("cls");
cout<<"==========================================\n";
cout<<"||\t\t\t\t\t||\n";
cout<<"||\t\tJAM DIGITAL\t\t\||\n";
cout<<"||\t\t  ";
cout<<jam<<":"<<menit<<":"<<detik;
cout<<"\t\t||\n";
cout<<"||\t\t\t\t\t||\n==========================================\n\n";
Sleep(1000);
detik=detik+1;
if (detik>59){
detik=0;
menit=menit+1;
if(menit>59){
menit=0;
jam=jam+1;
if(jam>23){
jam=0;
}
}
}
}
return 0;
}

hasil compile :




Related Posts:

  • C++ PROGRAM DERET FIBONACCI ITERATIF C++ PROGRAM DERET FIBONACCI ITERATIF #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; void fibonacci(int N){ int U1 = 0, U2 … Read More
  • C++ Program Rangkaian Listrik ( switch-case )C++ Program Rangkaian Listrik ( switch-case ) #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char… Read More
  • C++ PROGRAM BILANGAN (terbesar, terkecil, rerata)C++ PROGRAM BILANGAN (terbesar, terkecil, rerata) #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char … Read More
  • C++ Program Konversi Nilai UjianC++ Program Konversi Nilai Ujian #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char *argv[]) { … Read More
  • C++ PROGRAM PANGKAT (REKURSIF) C++  PROGRAM PANGKAT (REKURSIF) #include <iostream> #include <cstdlib> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int pangkat(… Read More

0 komentar:

Posting Komentar