Problem with program!

I am beginner at programming and i need help with this piece of code. I was trying to make program that will input 3 numbers and output them from slightest to greatest! Everytime i test it middle number is ok others are wrong. Help is appreciated!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>
int main()
{
	int a,b,c,max,min,mid;
	
	printf("Enter 3 numbers: \n");
	scanf("%d,%d,%d",&a,&b,&c);
	                    
	max=a;         
	
	if(b>max) max=b;
	if(c>max) max=c; 
        
//I want to use printf,scanf instead of cout,cin!
	
	min=a;
	
	if(b<min) min=b;
	if(c<min) min=c;
	
	mid=(a+b+c)-(max+min);
	
	printf("Numbers are printed from min to max:\n%d\n%d\n%d",min,mid,max);
	return 0;
}
How exactly are you entering the numbers? Entering 4,2,3 (comma separated numbers without whitespace) yields the expected result. If you want to separate the numbers using whitespace you should instead use:

scanf("%d %d %d",&a,&b,&c);
Oh yep it worked thanks for help!
Topic archived. No new replies allowed.