Program c++ Persegi panjang dan Segitiga

Sabtu, 18 Mei 2013


PROGRAM PERSEGI PANJANG
Coding :
#include<iostream.h>
#include<conio.h>
main()
{
  float luas,p,l;
  cout<<"  ============================  \n";
  cout<<"  Program Luas Persegi Panjang \n";
  cout<<"  ============================  \n";
  {
                                    cout<<"  >> Masukkan Panjang = ";
                                    cin>>p;
                                    cout<<"  >> Masukkan Lebar   = ";
                                    cin>>l;
                                    cout<<"  --------------- \n";
                                    cout<<"   Rumus = P x l\n";
                                    cout<<"  --------------- \n";
                                    luas=p*l;
                                    cout<<"  >> Luas Persegi Panjang = "<<luas;
                                    }
  getch();
}
  
PROGRAM SEGITIGA
Coding :
#include<conio.h>
#include<stdio.h>
#include<iostream.h>
main()
{
float luas_segitiga,alas,tinggi;
            cout<<" -------------------------- \n";
            cout<<"  MENGHITUNG LUAS SEGITiGA \n";
            cout<<" -------------------------- \n";

            cout<<" > Masukan Nilai Alas   = ";
                        cin>>alas;
            cout<<" > Masukan Nilai Tinggi = ";
                        cin>>tinggi;
            cout<<" --------------------------- \n";
            cout<<" > Rumus = (Alas x Tinggi)/2 \n";
            cout<<" --------------------------- \n";
            luas_segitiga=0.5*(alas*tinggi);
            cout<<" > Luas Segitiga        = "<<luas_segitiga<<endl<<endl;
            puts(" ============SELESAI============");
            getche();
}
 


Copyright @ 2013 Yudith's Blog. Designed by Templateism | MyBloggerLab