-
array in ascending order
hi
could u plz help me out with this array problem...in which i have to print "array elements in ascending order"....while compilation there is no error but when i run the code it shows the output as -- 24768, which is very weird. i have wriiten the code like this:::
#include<stdio.h>
#include<conio.h>
int main(void)
{
int a[10],temp,i,j;
clrscr();
printf("ENTER ARRAY ELELMENTS:");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
fflush(stdin);
for(i=0;i<10;i++)
{
for(j=j+1;j<10;j++)
{
if(a[i]>a[i+1])
{
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
}
}
printf("SORTED ARRAY IS:");
fflush(stdout);
for(i=0;i<10;i++)
printf("%d",a[i]);
fflush(stdout);
getch();
return 0;
}
-
can any 1 help me out with this code//////////plz
i don't know how to make this work..........?
plz help me out guys...........
-
Once you edit your post to include CODE tags, read all about them here:
http://cboard.cprogramming.com/showthread.php?t=25765
Which xErath mentioned in your last thread which is the same as this one (When the topics are this similar, keep posting in the same thread, there's no point in wasting room on the board with the same topic).
As I was saying, once you do that, you'll get more help.
Note: You still haven't given "j" an initial value along with many many more of Prelude's and Scribbler's suggestions in your last thread. It would be a good idea to read all the replies there more thoroughly and look at the differences between your code and Prelude's example.
-
-
How about you stop spamming the board, and stick to one thread.