What's new

Chinese Zodiac

What's your zodiac sign on the Chinese Zodiac?

  • Rat

    Votes: 2 28.6%
  • Ox

    Votes: 1 14.3%
  • Tiger

    Votes: 0 0.0%
  • Rabbit

    Votes: 0 0.0%
  • Dragon

    Votes: 1 14.3%
  • Snake

    Votes: 1 14.3%
  • Horse

    Votes: 1 14.3%
  • Sheep

    Votes: 1 14.3%
  • Monkey

    Votes: 0 0.0%
  • Chicken

    Votes: 0 0.0%
  • Dog

    Votes: 0 0.0%
  • Pig

    Votes: 0 0.0%

  • Total voters
    7

Exophase

Emulator Developer
You should consider using lookup tables when possible. That increment loop can also be replaced by something more direct.

Code:
#include <iostream>
using namespace std;
int main()
{
    int y;
    cout<<"Enter your year of birth:  ";
    cin>>y;

    if(y < 0)
      y = 12 - (-y % 12);

    if (y == 14) {cout<<"Really?  Me, too!";}
    char *signs[] = { "Monkey", "Chicken", "Dog", "Pig", "Rat", "Ox", "Tiger",
     "Rabbit", "Dragon", "Snake", "Horse", "Sheep" };

    cout << "You were born in the year of the " << signs[y % 12] << ".";

    cout<<"\n\n";
    system("PAUSE");
}

If you can't use a table, a switch statement is heavily preferred over a series of if's like this (and will likely be more efficient).
 

Top