3 Program untuk pertemuan ke tiga matakuliah Algoritma Pemrograman
Program Pertama
Mencari Bilangan Positif dan Negatif
#include <iostream>
#include <conio.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
main(){
int bil;
cout<<"Masukkan Bilangan yang akan dicek = ";
cin>>bil;
if (bil > 0)
cout<<bil<<" adalah bilangan Positif";
else if (bil < 0)
{
cout<<bil<<" adalah bilangan Negatif";
}
else if (bil==0)
{
cout<<"Anda mengInputkan bilangan Nol (0)\n";
}
else
{
cout<<"inputan salah";
}
getch();}
Program Pertama
Mencari Bilangan Positif dan Negatif
#include <iostream>
#include <conio.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
main(){
int bil;
cout<<"Masukkan Bilangan yang akan dicek = ";
cin>>bil;
if (bil > 0)
cout<<bil<<" adalah bilangan Positif";
else if (bil < 0)
{
cout<<bil<<" adalah bilangan Negatif";
}
else if (bil==0)
{
cout<<"Anda mengInputkan bilangan Nol (0)\n";
}
else
{
cout<<"inputan salah";
}
getch();}
Program ke dua
Menghitung Luas Persegi Panjang
#include <iostream>
#include <conio.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[])
{
int p,l;
cout<<":::Software Penghitung Luas Persegi Panjang:::"<<endl;
cout<<"masukkan nilai panjang= ";
cin>>p;
cout<<"masukkan nilai lebar= ";
cin>>l;
cout<<"Luas Persegi Panjang="; cout<<(p*l);
return 0;
}
Program ke tiga
Program Segitiga Bintang
#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 i,a,n;
cout<<"Wasys_N-The Sky\n\n";
cout<<"masukan jumlah baris ";
cin>>i;
for (n=1;n<=i;n++){
for (a=1;a<=n;a++){
cout<<"*";
}
cout<<endl;
}
return 0;
}
0 komentar:
Post a Comment