This repository has been archived on 2023-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
VSMechatronics/C9/ex4.c

22 lines
454 B
C
Raw Normal View History

2023-10-06 12:47:33 +00:00
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int age = 1; // Declare variable and initialise to 1
do {
printf ("\nPlease enter your age: ");
scanf("%d", &age);
printf ("You are %d years old\n", age);
if (age == 18 || age == 21) {
printf("You have come of age\n");
}
// Code now goes back and repeats the test with the value of age just entered
} while ( age != 0); // Loop as long as age is not zero
return 0; // Exit code
}