Program Help PLease!

Trying to square a number that is input by a user, the number must be BETWEEN 0 and 10. If its not im asked to terminate program. What am i doing wrong and why wont my code compile?

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
27
28
29
30
31
#include <iostream>
using namespace std;

int main ()
{
        double a;

        cout << "Please enter decimal number that is greater than
 0 but less than 10; " << endl;
        cin >> a;

        if ( a > 0 ) ( a < 10 )
        {

        cout << ( a * a ) << endl;

        }
        else
        {

        return 0;       

        }


"hw2.cpp" 33L, 329C written
[pejo9770@venus hw]$ g++ hw2.cpp
hw2.cpp: In function âint main()â:
hw2.cpp:18:2: error: expected â;â before â{â token
  {
if( a>0 and a<10 )
Or
 
if (a > 0 && a < 10)


It`s the same, only '&&' instead of 'and';
Topic archived. No new replies allowed.