Angga_Wahyu

C++ Program Training Function Parameters

Nov 7th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. float banding(float bil1,float bil2){
  5.     if (bil1>bil2)return bil1;
  6.     else return bil2;
  7.  
  8. }
  9. int min(int x, int y){
  10.     if (x<y)return x;
  11.     else return y;
  12. }
  13. int min(int x,int y, int z){
  14.     int temp;
  15.     if (x<y) temp=x;
  16.     else temp = y;
  17.     if (z<temp) temp = z;
  18.     return temp;
  19. }
  20. int min(int x,int y, int z,int w){
  21.     int temp;
  22.     if (x<y) temp=x;
  23.     else temp = y;
  24.     if (z<temp) temp = z;
  25.     if (w<temp) temp = w;
  26.     return temp;
  27. }
  28. main(){
  29.     float a,b;
  30.     int x,y,z,w;
  31.     cout<<"Masukkan Bilangan 1 : ";cin>>a;
  32.     cout<<"Masukkan Bilangan 2 : ";cin>>b;
  33.     cout<<"Bilangan Terbesar = "<<banding(a,b)<<endl;
  34.     cout<<"Bilangan 1 : ";cin>>x;
  35.     cout<<"Bilangan 2 : ";cin>>y;
  36.     cout<<"Bilangan 3 : ";cin>>z;
  37.     cout<<"Bilangan 4 : ";cin>>w;
  38.     cout<<"Minimum Bil1,Bil2 = "<<min(x,y)<<endl;
  39.     cout<<"Minimum Bil1,Bil2,Bil3 = "<<min(x,y,z)<<endl;
  40.     cout<<"Minimum Bil1,Bil2,Bil3,Bil4 = "<<min(w,x,y,z)<<endl;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment