This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Tampilkan postingan dengan label Info. Tampilkan semua postingan
Tampilkan postingan dengan label Info. Tampilkan semua postingan

Jumat, 04 Mei 2012

Program Menghitung Jumlah Rata-rata

Program Menghitung Jumlah rata-rata 



#include <iostream.h>

int main()
{
int aray[100];
int n;
float rata,jumlah=0;
cout<<"masukkan data sebanyak = ";
cin>>n;

for(int i=0;i<n;i++){
cout<<"masukkan nilai["<<i+1<<"] : ";
cin>>aray[i];

}
cout<<endl;


for(int i=0;i<n;i++){
cout<<"nilai["<<i+1<<"] : ";
cout<<aray[i]<<endl;
jumlah +=aray[i];
}
cout<<endl;

rata=jumlah/n;
cout<<"jumlah data adalah = "<<jumlah<<endl;
cout<<"rata-ratanya adalah = "<<rata;




return 0;
}

Program C++ Untuk Menampilkan Hari

Program C++ Untuk menampilakan nama hari



#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int hari;
 
    cout<<"menentukan hari"<<endl;
    cout<<"1=senin  3=rabu  5=jum'at  7=minggu"<<endl;
    cout<<"2=selasa  4=kamis  6=sabtu"<<endl;
    cout<<endl;
    cout<<"masukkan kode hari (1-7) : ";
    cin>>hari;
 
    if(hari==1)
    cout<<"senin"<<endl;
    else if(hari==2)
    cout<<"selasa"<<endl;
    else if(hari==3)
    cout<<"rabu"<<endl;
    else if(hari==4)
    cout<<"kamis"<<endl;
    else if(hari==5)
    cout<<"jum'at"<<endl;
    else if(hari==6)
    cout<<"sabtu"<<endl;
    else if(hari==7)
    cout<<"minggu"<<endl;
    else
    cout<<"kode ini tidak di kenal"<<endl;
    cout<<endl;
 
    system("PAUSE");
    return EXIT_SUCCESS;
}

Program Akar Kuadrat C++

Program Untuk menghitung Akar Kuadrat menggunakan Dev C++ . Dibawah ini adalah program c++ untuk menghitung akar kuadrat dengan menggunakan program


#include <cstdlib>
#include <iostream>
#include <math.h>

using namespace std;

int main(int argc, char *argv[])
{
    int a,b,c;
    long disk;
    float x1,x2;
   
    cout<<"koefesien pankat 2 : ";cin>>a;
    cout<<"koefesien pankat 1 : ";cin>>b;
    cout<<"koefesien pankat 0 : ";cin>>c;
   
    if(a==0){
             cout<<"bukan persamaan kuadrat"<<endl;
             cout<<"harga akar = "<<-c/b;}
    else{
         disk=b*b-4*a*c;
         if (disk>0){
                     x1=-b+sqrt(disk)/(2*a);
                     x1=-b-sqrt(disk)/(2*a);
                     cout<<"diskriminan = "<<disk<<endl;
                     cout<<"x1 = "<<x1<<endl;
                     cout<<"x2 = "<<x2<<endl;}
         else if(disk==0){
              x1=-b/(2*a);
              x2=x1;
              cout<<"diskriminan = 0"<<endl;
              cout<<"x1 = "<<x1<<endl;
              cout<<"x2 = "<<x2<<endl;}
         else
         cout<<"Akar imajiner"<<endl;
         }
         cout<<endl;
       
    system("PAUSE");
    return EXIT_SUCCESS;
}