M
mitchellpal
guys i need help here, what do i do to my code inorder to prompt the
user to enter any 10 integer values then display them in ascending
order?
#include<stdio.h>
#define SIZE 10
main()
{
int i;
int pass;//pass counter
int hold;//
long a[SIZE]={12,451,56,205,450,78,90,67,45,100};
//printf("Enter 10 integer values\n\n");
printf("\nElements in original array\n\n");
for(i=0;i<SIZE;i++){
printf("%4d",a);
}
printf("\n\n");
//pass counter
for(pass=0;pass<SIZE;pass++){
for(i=0;i<SIZE-1;i++){
if(a>a[i+1]){
hold=a;
a=a[i+1];
a[i+1]=hold;
}//endif
}//end inner for
}//end outer for
printf("Elements in ascending order\n\n");
for(i=0;i<SIZE;i++){
printf("%4d",a);
}//endfor
printf("\n\n");
}
the program is working as it is...... my email address is real too.
user to enter any 10 integer values then display them in ascending
order?
#include<stdio.h>
#define SIZE 10
main()
{
int i;
int pass;//pass counter
int hold;//
long a[SIZE]={12,451,56,205,450,78,90,67,45,100};
//printf("Enter 10 integer values\n\n");
printf("\nElements in original array\n\n");
for(i=0;i<SIZE;i++){
printf("%4d",a);
}
printf("\n\n");
//pass counter
for(pass=0;pass<SIZE;pass++){
for(i=0;i<SIZE-1;i++){
if(a>a[i+1]){
hold=a;
a=a[i+1];
a[i+1]=hold;
}//endif
}//end inner for
}//end outer for
printf("Elements in ascending order\n\n");
for(i=0;i<SIZE;i++){
printf("%4d",a);
}//endfor
printf("\n\n");
}
the program is working as it is...... my email address is real too.