"IF" problem

Hello, i´m new in this web and also programming,

I 'm trying to make a Chinese horoscope is supposed to be the user to write your name and the year I was born , but when I write some amount after the first number ( example : 1900 ( this work) 1912 , 1924 , 1936 ( these last do not work)
Any help ?
Thank You
And excuse my bad English , (spanish student)
(The names of the animals are in Spanish )

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
32
33
34
35
36
37
38
39
40
41
  #include <iostream>
#include <string>

using namespace std;

int main() {
		     string f; 	
			 cout << " Name "<<endl;
		     getline (cin,f);  
    int b;
    cout<< "Year "<<endl;
	cin>> b;
      if(b == 1900 && 1912 && 1924 && 1936 && 1948 && 1960 && 1972 && 1984 && 1996)
    cout << "Rata" <<endl;
    if(b == 1901&& 1913&& 1925&& 1937&& 1949&& 1961&& 1973&& 1985&& 1997)
    cout << "Bufalo" <<endl;
    if(b ==  1902&& 1914&& 1926&& 1938&& 1950&& 1962&& 1974&& 1986&& 1998)
    cout << "Tigre" <<endl;
    if(b ==  1903&& 1915&& 1927&& 1939&& 1951&& 1963&& 1975&& 1987&& 1999)
    cout << "Gato" <<endl;
    if(b ==  1904&& 1916&& 1928&& 1940&& 1952&& 1964&& 1976&& 1988&& 2000)
    cout << "Dragon" <<endl;
    if(b ==  1905&& 1917&& 1929&& 1941&& 1953&& 1965&& 1977&& 1989&& 2001)
    cout << "Serpiente" <<endl;
    if(b ==  1906&& 1918&& 1930&& 1942&& 1954&& 1966&& 1978&& 1990&& 2002)
    cout << "Caballo" <<endl;
    if(b ==   1907&& 1919&& 1931&& 1943&& 1955&& 1967&& 1979&& 1991&& 2003)
    cout << "Cabra" <<endl;
    if(b ==   1908&& 1920&& 1932&& 1944&& 1956&& 1968&& 1980&& 1992&& 2004)
    cout << "Mono" <<endl;
    if(b ==   1909&& 1921&& 1933&& 1945&& 1957&& 1969&& 1981&& 1993)
    cout << "Gallo" <<endl;
    if(b ==   1910&& 1922&& 1934&& 1946&& 1958&& 1970&& 1982&& 1994)
    cout << "Perro" <<endl;
    if(b ==   1911&& 1923&& 1935&& 1947&& 1959&& 1971&& 1983&& 1995)
    cout << "Jabali" <<endl;
system ("PAUSE");
return 0;
}

Your if statements are faulty. C++ does not support an implied left hand side.
You need to specify each comparison explicitly. Also, you want the OR operator, not the AND operator.

1
2
if (b==1900 || b==1912 || b==1924 || b==1936 || b==1948 || b==1960 || b==1972 || b==1984 || b==1996)
/// etc 


Last edited on
Thank you so much AbstractionAnon!
Topic archived. No new replies allowed.