PERTEMUAN 10 POINTER DAN MACRO
By Aldhen FY - May 04, 2018
Pointer dan Macro
Latihan 1
#include <iostream> #include <conio.h> #include <stdio.h> using namespace std; int main() { int ilham, amir,*raka; ilham = 75; amir = ilham; raka = &ilham; cout << "Nilai Ilham = " << ilham << endl; cout << "Nilai Amir = " << amir << endl; cout << "Nilai Raka = " << raka << endl; getch();
}
|
Tugas 10 Membuat Program Pointer dan Macro
Tugas 1
#include <iostream>
#include <conio.h>
#include <stdio.h>
#define x(y) y*y
#define xy(y) y*y*y
using namespace std;
int main()
{
cout<<"Bilangan Pangkat :
"<<endl;
cout<<"Pangkat 4^2 : "<<x(4)<<endl;
cout<<"Pangkat 4^3 :
"<< xy(4)<<endl;
}
|
Tugas 2
#include <stdio.h>
#include <iostream>
#include <conio.h>
#define v 3.141592
#define L(n) v*n*n
using namespace std;
main()
{
cout<<"Luas Lingkaran adalah " <<endl;
cout<<"Jari-jari= 5 adalah " <<L(5)<<endl;
cout<<"Jari-jari= 10 adalah " <<L(10)<<endl;
}
|
Tugas 3
#include <stdio.h>
#include <iostream>
#include <conio.h>
#include "atur.h"
using namespace std;
main()
{
float
nilai,na,nt,uas,uts,nila;
cetak<<"Program Hitung NIilai Akhir" <<enter;
cout<<"===========================" <<enter
<<enter;
cetak<<"Masukan Nilai" <<enter;
cout<<"===========================" <<enter
<<enter;
na= NA;
cout<<"Nilai Absensi
: " ;input>>na;
nt= NT;
cout<<"Nilai Tugas
: " ;input>>nt;
uts= UTS;
cout<<"Nilai UTS
: " ;input>>uts;
uas= UAS;
cout<<"Nilai UAS
: " ;input>>uas;
cout<<"===========================" <<enter
<<enter;
cetak<<"Hasil Nilai" <<enter;
cout<<"===========================" <<enter
<<enter;
cout<<"Nilai Absensi
= " <<NA
<<" (10%) dari " <<na <<enter;
cout<<"Nilai Tugas
= " <<NT
<<" (20%) dari " <<nt <<enter;
cout<<"Nilai UTS
= " <<UTS <<" (30%) dari " <<uts
<<enter;
cout<<"Nilai UAS
= " <<UAS <<" (40%) dari " <<uas
<<enter;
cout<<"===========================" <<enter;
nila=
NILA;
cout<<"Nilai Akhir
= " <<NILA
<<enter;
}
|
0 comments