60 likes | 171 Views
Pertemuan Ke-11. IF II UIN SGD. #include < iostream > using namespace std ; int kurang ( int a, int b) { int r; r=a-b; return (r); } int main () { int x=5, y=3, z; z = kurang (7,2); cout << " Angka Pertama : " << z << '<br>';
E N D
Pertemuan Ke-11 IF II UIN SGD
#include <iostream> using namespace std; intkurang(int a, int b) { intr; r=a-b; return (r); } intmain () { int x=5, y=3, z; z = kurang(7,2); cout << "AngkaPertama: " << z << '\n'; cout << "AngkaKedua: " << kurang(7,2) << '\n'; cout << "AngkaKetiga: " << kurang(x,y) << '\n'; z= 4 + kurang(x,y); cout << "AngkaKeempat: " << z << '\n'; system("pause"); return 0; } Latihan FUNGSI
#include <iostream> using namespace std; void duplikat(int& a, int& b, int& c) { a*=2; b*=2; c*=2; } int main () { int x=1, y=3, z=7; duplicate (x, y, z); cout << "x=" << x << ", y=" << y << ", z=" << z; system("pause"); return 0; }
#include <iostream> using namespace std; void MundurMaju (int x, int& mundur, int& maju) { mundur = x-1; maju = x+1; } intmain () { int x=100, y, z; MundurMaju(x, y, z); cout << "Mundur=" << y << ", Maju=" << z; system("pause"); return 0; }
#include<iostream> //f(x)=2x*x+5x using namespace std; float F(float x){ float z = (2*x*x)+(5*x); return z; } intmain(){ float x; cout << "---------------------------\n"; cout << " x f(x) \n"; cout << "---------------------------\n"; x=10.0; while(x<=15.0){ cout << x << " " << F(x)<<"\n"; x=x+0.5; } cout << "---------------------------\n\n"; system("pause"); }
BUAT DALAM 1 PROGRAM: • BUAT PROGRAM DERET FIBONACCI DENGAN FUNGSI • BUAT RUMUS PHYTAGORAS DENGAN FUNGSI • BUAT FUNGSI JARAK: D= • BUAT FUNGSI MENGHITUNG AKAR-AKAR FUNGSI KUADRAT: TUGAS 7