1. ## urgently required help!!!

i need to know how to sort out four variables in ascending order via pointers w/o use of arrays, and && operators...
do we make individual sorting cases...in this case 24 for 4 variables or sort the first three first and then introduce the third variable at the end...i've been trying for agaes...always get stuck and in the army of nested if and if else!!

2. Okay . . . why don't you use a function like this?
Code:
```void sort2(int *a, int *b) {

}```
Then you could have a function like this.
Code:
```void sort3(int *a, int *b, int *c) {

}```
etc.

3. Find minimum of 4 value using min (it will be first)
Find maximum of 4 value using max (it will be 4th)
Fin 2 values that are different from two above
minimum of them will be 2nd, maximum = 3rd

4. Code:
```#include<stdio.h>
#include<conio.h>
void sort (int*ptr1,int*ptr2,int*ptr3,int*ptr4);
void main()
{
int a,b,c,d,*ptr1,*ptr2,*ptr3,*ptr4;
clrscr();
printf("enter four nos:");
scanf("%d%d%d%d",&a,&b,&c,&d);
sort(&a,&b,&c,&d);
printf("\n\n%d-->%d-->%d-->%d\n\n",a,b,c,d);
getch();
}
void sort(int*ptr1,int*ptr2,int*ptr3,int*ptr4)
{
int a=*ptr1,b=*ptr2,c=*ptr3,d=*ptr4;
if(a<b);//-a-b- case
{if(c<a);{*ptr1=c;*ptr2=a;*ptr3=b;}//-c-a-b-
{if(d<c){*ptr1=d;*ptr2=c;*ptr3=a;*ptr4=b;}//dcab
else if(d>c){*ptr2=d;*ptr1=c;*ptr3=a;*ptr4=b;}//cdab
else(d>b);{*ptr1=c;*ptr2=a;*ptr3=b;*ptr4=d;}//cabd
}
if(b<c);//-a-b-c- case
{if(d<a){*ptr1=d;*ptr2=a;*ptr3=b;*ptr4=c;}//dabc
else if(d>b){*ptr3=d;*ptr4=c;}//abdc
else(d>c);//abcd
}
if(c<b);{*ptr2=c;*ptr3=b;}//-a-c-b-
{if(d<a){*ptr1=d;*ptr2=a;*ptr4=b;}//dacb
else if(d>c){*ptr2=c;*ptr3=d;*ptr4=b;}//acdb
else (d>b);{*ptr2=c;*ptr3=b;}//acbd
}
}

if(c<b);{*ptr1=c;*ptr3=a;}//-c-b-a-
{if(d<c){*ptr1=d;*ptr2=c;*ptr3=b;*ptr4=a;} //dcba
else if(d>c){*ptr1=c;*ptr2=d;*ptr3=b;*ptr4=a;}//cdba
else if(d>b){*ptr1=c;*ptr3=d;*ptr4=a;}//cbda
}
if(a<c);{*ptr1=b;*ptr2=a;}//-b-a-c-
{if(d<b){*ptr1=d;*ptr3=a;*ptr4=c;}//dbac
else if(d>b){*ptr1=b;*ptr2=d;*ptr3=a;*ptr4=c;}//bdac
else(d>c);{*ptr1=b;*ptr2=a;}//bacd
}
if(c<a);{*ptr1=b;*ptr2=c;*ptr3=a;}//-b-c-a-
{if(d<b){*ptr1=d;*ptr4=a;}//dbca
else if(d>b){*ptr1=b;*ptr2=d;*ptr4=a;}//bdca
else if(d>c){*ptr1=b;*ptr2=c;*ptr3=d;*ptr4=a;}//bcda
}
}```
...this is the code i worked out...isn't working anywyz..plz help!!

5. Don't use void main() . . . http://faq.cprogramming.com/cgi-bin/...&id=1043284376

Break it up into functions like I suggested.

6. i've been asked to develop a single fuction for the task of sorting that should be usable in void main()...any help?

7. Maybe tell us what the problem is instead of saying 'isn't working anywyz..plz help!!'

8. Well, whoever told you to use void main is wrong. It doesn't matter if [s]he's your teacher or if they're a professional programmer. void main is wrong.

This doesn't do what you think it does.
Code:
`if(a<c);{*ptr1=b;*ptr2=a;}//`
The extra semicolon makes the compiler see that as
Code:
```if(a<c){}
*ptr1=b;*ptr2=a;```
so it's always executed.

 As for the problem . . .

Code:
```if a > b then swap(a,b)
if b > c swap(b,c)
if c > d swap(c,d)
// now d is the highest number
if a > b then swap(a,b)
if b > c swap(b,c)
// now c is the second-highest
// ...```
[/edit]

9. Cheat.

Build a singly linked list and sort the list. It fits all the requirements:
- uses pointers and not arrays
- you can code a sorting algorithm for linked lists without &&
- one sort function that works in main.