#include <stdio.h>
int main()
{
int age;
printf("Acme movie theatre\n");
printf("Input your age: ");
scanf("%d", &age);
if (age < 21)
{
printf("You are too young to watch this movie.\n");
}
return 0;
}
|
- Try to run this program.
- When you input the age with the number of less than 21, what happened?
You get the message: "You're too young to watch this movie."
- If you input the age with 21 or more, then nothing gets printed.
Why? Because the condition age < 21 is not satisfied,
and thus the computer skip the commands within the braces.
|