Added book examples

This commit is contained in:
Louise Brown
2022-04-08 16:12:38 +01:00
parent 5b205092a7
commit 1c0a9e7b6a
59 changed files with 1381 additions and 0 deletions

24
C9/do_while_loop.c Normal file
View File

@@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int age; // Declare variable, no need to initialise this time
// as we read into it before it is tested against
// The loop is always entered as the test is at the end
do
{
// Code must be executed at least once
printf ("\nPlease enter your age");
scanf("%d", &age);
printf ("You are %d years old\n", age);
// Test is now made and the code
// repeats if the test equates as non-zerp
// (i.e. is age is not zero)
}
while ( age != 0);
return 0;
}