Minggu, 28 Juni 2015

Konversi detik ke Jam, Menit dan Detik

Program Konversi detik ke Jam, Menit dan Detik dengan DEV C++

#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) {

double a,b,c,d;

cout<<"Masukkan nilai jam dalam detik = ";cin>>a;
b=a/3600;
c=a/60;
d=a/1;
cout<<b<<"Jam "<<c<<"Menit "<<d<<"Detik";
return 0;

}




Wujud Air

Program Wujud Air dengan DEV C++

#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 main(int argc, char** argv) {

float A;

cout<<"Masukkan suhu air dalam Celcius = ";cin>>A;

if ((A>=0) && (A<=100))
cout<<"Wujudnya cair";
else if (A>100)
cout<<"Wujudnya uap";
else
cout<<"Wujudnya padat";

cout<<endl;
system("PAUSE");
return 0;
}


Deret Fibonacci

Deret Fibonacci dengan DEV C++

#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) {
int a, b, c, d, e;

cout<<"Deret Fibonacci\n";
    cout<<"Masukkan bilangan : ";cin>>a;
     c=1;d=1;
     cout<<c<<endl<<d<<endl;
     for(int b=3; b<=a; b++)
    {
    e = c + d;
    c = d;
    d = e;

     cout<<e<<endl;
     }
return 0;
}






















Deret Fibonacci dengan Pascal





















Tukar 3 Bilangan

Program Tukar 3 Bilangan dengan DEV C++

#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) {

int A=5, B=2, C=3, D;

cout<<"A = "<<endl;cin>>A;
cout<<"B = "<<endl;cin>>B;
cout<<"C = "<<endl;cin>>C;

D=A;
A=B;
B=C;
C=D;

cout<<endl;
cout<<"A = "<<A<<endl;
cout<<"B = "<<B<<endl;
cout<<"C = "<<C<<endl;
return 0;

}





Program Tukar 3 Bilangan dengan Pascal