Mengurutkan 4 Bilangan Ascending dengan IF C++

Wahyu Raja Butar-Butar Reply 20:07
Berikut Source Codenya :

#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,d,x;

printf("a : ");
scanf("%d",&a);

printf("b : ");
scanf("%d",&b);

printf("c : ");
scanf("%d",&c);

printf("d : ");
scanf("%d",&d);

if(b<a)
{
x=b;
b=a;
a=x;
}
if(c<a)
{
x=c;
c=a;
a=x;
}
if(d<a)
{
x=d;
d=a;
a=x;
}
if(c<b)
{
x=b;
b=c;
c=x;
}
if(d<a)
{
x=a;
a=d;
d=x;
}
if(d<b)
{
x=b;
b=d;
d=x;
}
if(d<c)
{
x=c;
c=d;
d=x;
}

printf("setelah diurutkan %d %d %d %d",a,b,c,d);

getch();
return 0;
}

Related Posts

Programming 5375608567082894628
Comments
0 Comments
Facebook Comments by Media Blogger

Post a Comment

Search

Google+ Followers

Popular Posts

Translate