+ 2
Help!
I wanna write a C++ program that reads 3 numbers & puts them in ascending order using if.else ,,can anyone give me some idea??
2 Réponses
+ 4
take a look [c program] translate it
#include<stdio.h>
void main()
{
int arr[1000],k,s,load,temp;
printf("Enter the size of array=");
scanf("%d",&s);
for(k=1;k<=s;k++)
{
printf("Enter the value %d=",k);
scanf("%d",&arr[k]);
}
for(k=1;k<=s;k++)
{
temp=1;
while(temp<s-k+1)
{
if(arr[temp]>arr[temp+1])
{
load=arr[temp];
arr[temp]=arr[temp+1];
arr[temp+1]=load;
temp=temp+1;
}
else
{
temp=temp+1;
}
}
}
printf("arr[%d]={",s);
for(k=1;k<=s;k++)
{
printf("%d",arr[k]);
if(k<s)
printf(",");
}
printf("}");
}
+ 2
@Ajay Bura thank you alot!