A logic Problem

I just start to study c++. I'm reading Deitel&Deitel 8th Edition. There are questions after chapter. I solved many of them. But I cant solved this one:

"(Arithmetic, Smallest and Largest) Write a program that inputs three integers from the keyboardandprints the sum, average, product, smallest and largest of these numbers. Use only the programming techniques you learned in this chapter."


I have learned "<, >, >=, <=, !=, ==, =, if, % and only int numbers" so i must solve this problem by these operators and statements. I tried to do something like this:

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
26
  #include <cstdlib>
#include <iostream>

using std::cout;
using std::cin;
int main(int argc, char *argv[])
{   
    int x;
    int y;
    int z;
    int f;
    int g;
    cout << " Please give me 3 number to compare : " ;
    cin >> x >> y >> z ;
    cout << "Sum:" << x + y + z ;
    cout << "Product:" << x*y*z ;
    cout << " Average: " << (x+y+z)/ 3 ;
    f=x%y;
    g=y%x;
    cout<< f ;
    if (f < 1)
       cout << "1. is the smallest number.\\n" ;
    if (g < 1 ) 
       cout<< "2. number is smallest.\\n";
    system("PAUSE");
    return EXIT_SUCCESS;
if (x<y){
if (x<z)
then x is smallest;
}
Topic archived. No new replies allowed.