Imported from my original Blogspot archive (2007–2010). Posts are preserved as originally written, including language, formatting, and mistakes.

It is a code of a program and is using for calculate an exercise that had in the test of mathematical Olympic championship, completed in July 12, 2005.

The question is:

Rabbits and chickens are in cage, counting from above there are 35 heads, counting from below there are 94 feet. How many chickens and how many rabbits are in the cage?

The C++ code:

/* r_and_c.c */
#include <conio.h>
#include <stdio.h>
int main(void)
{
 int Head, Feet;
 printf("Please input total feets:");scanf("%d", &Feet;);
 printf("Please input total heads:");scanf("%d", &Head;);
 clrscr();
 if(Head > (Feet / 2)) printf("Feets don't enough.");
 else if(Feet > (Head * 4)) printf("Feets have much.");
 else{
  int Temp;
  Temp = (Feet / 2) - Head;
  printf("Rabbit have %d\n", Temp);
  printf("Chicken have %d\n", Head - Temp);
 }
 getch();
 return(0);
}