1. ## Reordering numbers

helllo guys. I'm having problem with this question:
Write a program in C involving the use of pointers to reorder a list of numbers so that any of the following arrangements can be carried out :

a) smallest to largest by magnitude
b) smallest to largest, algebraic (by sign)
c) largest to smallest, by magnitude
d) largest to smallest, algebraic

Here is my coding:
Code:
```#include <stdio.h>
#include<math.h>

void main()
{
int selection,count;
float nums[10];

printf("\n 1. reorder from smallest to largest, by magnitude");
printf("\n 2. reorder from smallest to largest, algebraically");
printf("\n 3. reorder from largest to smallest, by magnitude");
printf("\n 4. reorder from largest to smallest, algebraically");
printf("\n****************************************************");
scanf("%d",&selection);

for(count=0;count<=9;++count)
{
printf("\nEnter a number:");
scanf("%d",&nums[count]);
}

switch (selection)
{
case 1:
reorder1(nums);
break;

case 2:
reorder2(nums);
break;

case 3:
reorder3(nums);
break;

case 4:
reorder4(nums);
break;
}
getchar();
}
int reorder1(float nums[])
{
float item,temp;
int count,a;

for (item=0;item<=9;++item)
for (a=item+1;a<=9;++a)
if(abs(nums[item])>abs(nums[a]))
{
temp=nums[item];
(nums[item])=(nums[a]);
(nums[a])=temp;
}
for (count=0;count<=9;++count)
{
printf("%f",nums[count])
printf("\n");
}
return;
}

int reorder2(float nums[])
{
float item,temp;
int count,a;

for (item=0;item<=9;++item)
for (a=item+1;a<=9;++a)
if((nums[item])>(nums[a]))
{
temp=nums[item];
nums[item]=nums[a];
nums[a]=temp;
}
for (count=0;count<=9;++count)
{
printf("%f",nums[count])
printf("\n");
}
return;
}

int reorder3(float nums[])
{
float item,temp;
int count,a;

for (item=0;item<=9;++item)
for (a=item+1;a<=9;++a)
if(abs(nums[item])<abs(nums[a]))
{
temp=nums[item];
nums[item]=nums[a];
nums[a]=temp;
}
for (count=0;count<=9;++count)
{
printf("%f",nums[count])
printf("\n");
}
return;
}
int reorder4(float nums[])
{
float item,temp;
int count,a;

for (item=0;item<=9;++item)
for (a=item+1;a<=9;++a)
if(nums[item]<nums[a])
{
temp=nums[item];
nums[item]=(nums[a]);
nums[a]=temp;
}
for (count=0;count<=9;++count)
{
printf("%f",nums[count])
printf("\n");
}
return;
}```
Im having about 30 errors while im trying to build the program...

2. Yes, I get a lot of errors too
Code:
```\$ gcc -W -Wall -ansi -pedantic -O2 foo.c
foo.c:5: warning: return type of 'main' is not `int'
foo.c: In function `main':
foo.c:22: warning: int format, float arg (arg 2)
foo.c:28: warning: implicit declaration of function `reorder1'
foo.c:32: warning: implicit declaration of function `reorder2'
foo.c:36: warning: implicit declaration of function `reorder3'
foo.c:40: warning: implicit declaration of function `reorder4'
foo.c: In function `reorder1':
foo.c:52: warning: implicit declaration of function `abs'
foo.c:52: error: array subscript is not an integer
foo.c:54: error: array subscript is not an integer
foo.c:55: error: array subscript is not an integer
foo.c:61: error: parse error before "printf"
foo.c:63: warning: `return' with no value, in function returning non-void
foo.c: In function `reorder2':
foo.c:73: error: array subscript is not an integer
foo.c:75: error: array subscript is not an integer
foo.c:76: error: array subscript is not an integer
foo.c:82: error: parse error before "printf"
foo.c:84: warning: `return' with no value, in function returning non-void
foo.c: In function `reorder3':
foo.c:94: error: array subscript is not an integer
foo.c:96: error: array subscript is not an integer
foo.c:97: error: array subscript is not an integer
foo.c:103: error: parse error before "printf"
foo.c:105: warning: `return' with no value, in function returning non-void
foo.c: In function `reorder4':
foo.c:114: error: array subscript is not an integer
foo.c:116: error: array subscript is not an integer
foo.c:117: error: array subscript is not an integer
foo.c:123: error: parse error before "printf"
foo.c:125: warning: `return' with no value, in function returning non-void```
Sure, you delete the source file and start again.
But before you sit down and try and "eat the whole elephant at one sitting", have a good read of this.

Then consider a more measured approach where you
- write a bit
- compile it
- test it

Rather than this "big bang" approach you have at the moment.

3. hahhaah.. ya thanks for ur advance

4. Well that really depends on whether you want to learn how to write programs doesn't it?

Smashing your face into the keyboard until you have a "complete" program, then trying to compile the result (and failing miserably), then posting the whole sorry mess on a message board for some other schmoe to debug for you is NOT a long term strategy.

So you may as well buckle down and learn how to write code in such a way that you can cope with whatever the compiler throws at you. This means learning the mantra of "compile often".