Programing in "C" ---help

hello,,,
can someone help me ,,i am beginner in this,,,

this is my home work:

Write an algorithm that will be of three integers find the maximum and minimum, and calculate the difference between the two. Write an algorithm for the programming language C and draw a diagram.
Post what you've got so far and what you're having trouble with.
with alll man ,,,i say i am beginner in this areaaa
You also say it's your homework.
yes i say,,i am first year on univerzity electrotehnical ing ,,,,or explain some....i write some but i donot know how to continueee..........i dont know is it ok

#include <stdio.h>
#include <stdlib.h>

int main()
{
int a;
int b;
int c;
int min;
int max;
a=2;
b=4;
c=6;

if(b>a)
{
max = b, min = a;
}
if(b<a)
{
min = b, max = a;
}
if(c>a)
{
max = c, min = a;
}
if(c<a)
{
max = a, min = c;
}
if(c>b)
{
max = c, min = b;
}
if(c>b)
{
max = b, min = c;
}
can you help?
Where you have commas, those should actually be on separate lines that each end with semicolons.
i donot know men,,,, imposible to get a result (max - min ) i donot know have tooo do this ,,,,if you know you write me some exampes or help me in some way....
will you help me ,,,,say me that i know what to do or wait you
Incorrect:
max = b, min = a;

Correct:
1
2
max = b;
min = a;
You need to put code tags around your code so we can comment on line numbers.

Here is what you need to figure out

1
2
3
4
5
6
7
8
9
10
11
    A               B               C
a<b   a>b      b<a  b>a      c<a  c>a
a<c   a>c       b<c  b>c       c<b  c>b

A B C
A C B
B A C
B C A
C A B
C B A

Right now your formula doesn't work but your code won't compile, so first get it to compile. You only need a } at the end.

Then you need to add some output so you can see if your formula is good.

you do not need
if(b<a)
you found that out with
if(b>a).

You can use

1
2
3
4
5
6
7
8
9
10
11
12
13
if ((a<b) && (b<c))
{
   cout << "ABC" << endl;
}
else
if ((a<b) && (b>c))
{
   cout << "ACB" << endl;
}
else
{
   cout << "Must be something else" << endl;
}
Last edited on
how to calculate diference bettwen two max and min
Same as always; max - min.
cout << " Diff " << (max-min) << endl;
Topic archived. No new replies allowed.