Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I need output is that,
Output:

Enter the numbers (3 numbers)= 4,6,3 (a,b,c) < integer

a is middle
b is big and
c is small.

More example: 6,6,4 << a,b,c integer

a and b is same and c big small from them.



<<<< like this! I need program which I can't do by myself. I am newbie. I start c program. So, please if you can better to do but, if else statement and by using C program.

Thanks in advance


Moved from "answer" by PIEBALDconsult -- some trouble with cleaning up the bad XML encoding, there may still be errors caused by this, but there are certainly bugs in the original. I did what I could.

I am sorry! Did you mind with my talks? Well, I am really sorry again :)

Any way, I did this!

C++
#include <stdio.h>
#include <conio.h>
int main ()
{	int a,b,c;

printf("\nEnter 3 numbers:");
scanf("%d %d %d",&a,&b,&c);

	
	if (a==b && a<c mode="hold" )	{
	
	printf ("a and b is same and small from c");
}
	else if (a==b && a>c || b>c)
	{
	
	printf ("a and b is same and big from c");
}
	else if (a==c && a<b mode="hold" )	{
	
	printf ("a and c is same and small from b");
}
	else if (a==c && a>b || c>b)
	{
	
	printf ("a and c is same and big from b");
}
	else if  (b==c && b>a || c>a)
	{
	
	printf ("b and c is same and big from a");
	
}
break;
	else if ((b==c) && (b<a))	{
	
	printf ("b and c is same and small from a");
}
	else if (a/b && b/c )
	{
	
	printf ("a is big\n b is middle \n c is small");
}
	else
	{
	 
	printf (" is nagitive");
}
	getch ();
}


But I don't know where is that error. Error is coming. Please you may check. And this is incomplete yet.
Posted
Updated 1-Nov-14 8:02am
v2
Comments
[no name] 1-Nov-14 12:47pm    
You described what you Need to solve.
What you have tried so far?

On a first step I would suggest to sort the three (try to think more General and sove it for any number of inputs) Inputs.

After this evaluate the sorted Input.
PIEBALDconsult 1-Nov-14 12:48pm    
We will not do your work for you. Ever.
Try it. Break the program into parts and work on each part one at a time.

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

And I'll not give you the code, but I'll give you the idea.
Sorting the inputs (as Bruno suggested) is the way to go, but a generic sort is probably a bit difficult at the moment, and you are supposed to use an if and else construct.

So sort them like this:
1) Compare a and b. If a is bigger than b, then do step 2, otherwise, skip it.
2) Swap a and b.
3) a now contains the smaller, b the larger. So compare b and c, and do the same thing - which give you the largest number of the three in c
4) Compare a and b again, and swap if necessary.

a now contains the smallest, b the middle, and c the largest. (This is a very simple version of what is called a Bubble Sort - because it "bubbles" the largest values up the list).

Now all you need to do is print them.
 
Share this answer
 
Comments
[no name] 1-Nov-14 13:26pm    
Sometime in the future maybe I'm also on the point so as to propose a solution like this (Google translate "swiss" german --> english) ;) My 5
Member 11198272 1-Nov-14 13:51pm    
::moved into the question by PIEBALDconsult::
PIEBALDconsult 1-Nov-14 14:05pm    
Don't put such huge content in a comment. I moved the code to the question, where you should have put it.
OriginalGriff 1-Nov-14 14:41pm    
OK, that's rather... Odd.

What is that "break" doing in there? :laugh: That is only allowed in "switch" statements or loops, so get it out!

Now, start again, and try doing it a bit at a time.
Try comparing just a and b, and see if you can get reliable, sensible answers for that before you start on c as well.
Hint:
if ( a less than b)
{
...
}
else if ( a equals b)
{

}
else
{
...
}

Try and code that and show us when you have it working.
PIEBALDconsult 1-Nov-14 15:03pm    
It's good to take a break when you don't know what you're doing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900