Monday, 16 March 2015

Mencari Nilai Tertinggi


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

main(){
int a[3];


   for (int i=0;i<3;i++){
    cout<<"Masukkan angka "<<i+1<<" : ";
    cin>>a[i];
   }
   int x;
   for (int i=0;i<2;i++)
    for (int j=i+1;j<3;j++){
    if (a[i]>a[j]){
          x=a[i];
            a[i]=a[j];
            a[j]=x;
         }
    }

   cout<<"\nTertinggi : "<<a[2];
   cout<<"\nTengah : "<<a[1];
   cout<<"\nTerendah : "<<a[0];

getche();//header conio.h
}



Sumber : http://ilmusayabagi.blogspot.com/2013/03/c-mencari-nilai-tertinggi.html

No comments:

Post a Comment

Konversi Suhu

#include <iostream> #include <conio.h> //#include <cstdlib> //#include <iostream.h> void main( float Celcius, Kelvi...