Tampilkan postingan dengan label pert4. Tampilkan semua postingan
Tampilkan postingan dengan label pert4. Tampilkan semua postingan

Kamis, 24 Maret 2016

contoh penggunaan while

#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) {
                {
                char tek[12]="INFORMATIKA";
                int i=0;
                while (tek[i]!=NULL)
                {
                cout<<tek[i]<<endl;
                i++;
                }
                }
                return 0;

}

contoh if else

#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) {
                { char ch;
                cout<<"Masukkan Sembarang Karakter :";cin>>ch;
                if((ch>='a'&& ch<='z')||(ch>='A'&& ch<='Z'))
                {cout<<" Yang Anda Ketik Adalah Alphabet";      }
                else
                {cout<<"Yang anda Ketik Bukan Alphabet";         }
                }
                return 0;
}

Selasa, 22 Maret 2016

mencari konversi suhu

#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
/*cara menghitung suhu*/

using namespace std;
int main(int argc, char** argv) {
{              int c;
                float r,f,k;
                cout<<"masukkan suhu c :";
                cin>>c;
                                r=4/5*c;
                                r=4/(float)5*c;
                                f=(9/5*c)+32;
                                k=c+273;
                                cout<<"nilai suhu c= "<<"\t r= "<<r<<"\t f= \t k= "<<f;
                }
                return 0;
}