Breaking News

Laman

Selasa, 03 April 2012

Modul VIII Pointer

This page is a collection of several examples of programs that implement the pointer, I hope this program can be beneficial.

#include <iostream.h>
#include <conio.h>

//deklarasi fungsi
float kalku(float*a, float*b);
float tam(float*a, float*b);
float kur(float*a, float*b);
float kal(float*a, float*b);
float bag(float*a, float*b);


void main()
{
int pil;
float b1,b2;
float tam(float*a, float*b);
float kur(float*a, float*b);
float kal(float*a, float*b);
float bag(float*a, float*b);
//masukkan bilanggan
cout<<"=================================================\n";
cout<<"=              Kalkulator Sederhana             =\n";
cout<<"=================================================\n";
cout<<"= Masukkan bilanggan pertama :"; cin>>b1;
cout<<"\n= Masukkan bilanggan kedua :"; cin>>b2;
cout<<"\n=================================================\n";
//menu oprasi
cout<<"=  1. Penambahan.\n";
cout<<"\n=  2. pengurangan.\n";
cout<<"\n=  3. perkalian.\n";
cout<<"\n=  4. Pembagian.\n";
cout<<"=================================================\n";
cout<<"Masukkan Pilihan Oprasi yang anda inginkan :"; cin>>pil;
cout<<"\n=================================================\n";
//mengeluarkan fungsi dengan if
if(pil==1)
{cout<<"Hasil penjumlahannya adalah :"<<tam(&b1,&b2);}
else if(pil==2)
{cout<<"Hasil pengguranggannya adalah :"<<kur(&b1,&b2);}
else if(pil==3)
{cout<<"Hasil perkaliannya adalah :"<<kal(&b1,&b2);}
else if(pil==4)
{cout<<"Hasil Pembagiannya adalah :"<<bag(&b1,&b2);}
cout<<"\n=================================================\n";
getch();
}
float tam(float*a,float*b)
{
float hsl;
hsl=*a+*b;
return hsl;
}
float kur(float*a,float*b)
{
float hsl;
hsl=*a-*b;
return hsl;
}
float kal(float*a,float*b)
{
float hsl;
hsl=*a**b;
return hsl;
}
float bag(float*a,float*b)
{
float hsl;
hsl=*a / *b;
return hsl;
}

Tidak ada komentar:

Designed By