Menghitung Total dan Rata-rata Beserta Pointer(Pengalamatan).
Below
I will give the C ++ coding calculate the total and the average value
and give the address or the more known as the pointer. in a coding there are 3 stages to be done that is input, process, and output. here I create a procedure that is by the name of the task and create a code input value by inputted freely. just go to the tutorial.
Code
#include <iostream.h>
#include <conio.h>
void tugas(){ //prosedur dengan nama tugas
int a,b,c;
float total,rata;
float *x,**xx;
//menginputkan nilai secara bebas
cout<<"\n masukkan nilai a : ";
cin>>a;
cout<<" masukkan nilai b : ";
cin>>b;
cout<<" masukkan nilia c : ";
cin>>c;
//proses untuk memnghitung nilai
total=a+b+c;
rata=total/3;
//mengeluarkan hasil dari total dan rata-rata
cout<<"\n total : "<<total<<endl;
cout<<" rata-rata : "<<rata<<endl;
//pengalamatan atau yang lebih dikenal dengan pointer
x=&total;
xx=&x;
cout<<"\n\n\n";
cout<<" total : "<<*x<<" alamat : "<<x<<endl;
cout<<" rata-rata : "<<**xx<<" alamat : "<<xx<<endl;
}
void main(){
tugas();
getch();
}
Output
Well that is the code to calculate the total and the average number of values that are input freely. hopefully you understand with the codes C + + is very simple and can develop it so be a reliable progremmer. hopefully this tutorial provides benefits for those of you who again learn C ++ programming. If anything is wrong in my writing, I apologize profusely. Thank you for following my tutorials.
Code
#include <iostream.h>
#include <conio.h>
void tugas(){ //prosedur dengan nama tugas
int a,b,c;
float total,rata;
float *x,**xx;
//menginputkan nilai secara bebas
cout<<"\n masukkan nilai a : ";
cin>>a;
cout<<" masukkan nilai b : ";
cin>>b;
cout<<" masukkan nilia c : ";
cin>>c;
//proses untuk memnghitung nilai
total=a+b+c;
rata=total/3;
//mengeluarkan hasil dari total dan rata-rata
cout<<"\n total : "<<total<<endl;
cout<<" rata-rata : "<<rata<<endl;
//pengalamatan atau yang lebih dikenal dengan pointer
x=&total;
xx=&x;
cout<<"\n\n\n";
cout<<" total : "<<*x<<" alamat : "<<x<<endl;
cout<<" rata-rata : "<<**xx<<" alamat : "<<xx<<endl;
}
void main(){
tugas();
getch();
}
Output
Well that is the code to calculate the total and the average number of values that are input freely. hopefully you understand with the codes C + + is very simple and can develop it so be a reliable progremmer. hopefully this tutorial provides benefits for those of you who again learn C ++ programming. If anything is wrong in my writing, I apologize profusely. Thank you for following my tutorials.
Komentar
Posting Komentar