fork(9) download
  1. #include <stdio.h>
  2.  
  3. int main() /* Most important part of the program! */
  4. {
  5. int age; /* Need a variable... */
  6.  
  7. printf( "Please enter your age" ); /* Asks for age */
  8. scanf( "%d", &age ); /* The input is put in age */
  9.  
  10. if ( age < 0 || age > 200) {
  11. printf("\nImpossible!\n");
  12. }
  13. else if (age >= 13 && age <= 19) {
  14. printf("\nYou're a teenager\n");
  15. }
  16. else if ( age < 100 ) { /* If the age is less than 100 */
  17. printf ("\nYou are pretty young!\n" ); /* Just to show you it works... */
  18. }
  19. else if ( age == 100 ) { /* I use else just to show an example */
  20. printf( "\nYou are old\n" );
  21. }
  22. else {
  23. printf( "\nYou are really old\n" ); /* Executed if no other statement is */
  24. }
  25.  
  26. if (age == 60) {
  27. printf("You should retire.");
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0s 2164KB
stdin
60
stdout
Please enter your age
You are pretty young!
You should retire.