Sorting 3 integers in C language

Solved
sophie85 -  
 sophie85 -
Bonjour,

I want to sort 3 integers in ascending order

when I input for example 5 8 3
the result is not 3 5 8 but 0 0 0

could you look at my code and tell me where the problem is

thank you :)

int a,b,c,p; cout<<"Please enter 3 numbers:\n"; cin>>a>>b>>c; if(c<a) p=c; c=a; a=p; if(b<a) p=b; b=a; a=p; if(c<b) p=c; c=b; b=p; cout<<a<<b<<c<<"\n";
Configuration: Windows Vista Internet Explorer 7.0

3 answers

loupius Posted messages 789 Status Member 148
 
It's 'C', not Python... A random question: didn't you forget some parentheses?
Good luck in the world of 'C'.
0