Week 1 Code Examples
#include <stdio.h>
#define PI 3.14159
#define AGE 26
int main(void) {
char letter;
printf("Enter a letter: ");
scanf(" %c", &letter);
printf("%c is a letter!\n", letter);
return 0;
}
//Henry's awesome code
#include <stdio.h>
int main(void) {
age = age + 1;
printf("Hello world!\n");
return 0;
}
#include <stdio.h>
int main(void) {
int age;
age = 26;
int fave_survivor_season = 17;
printf("My name is Henry, my age is %d and my favourite season of Survivor is season %d!\n", age, fave_survivor_season);
printf("Survivor season 17 is so GOATED!\n", fave_survivor_season);
printf("Survivor 17 actually sucks\n", fave_survivor_season);
return 0;
}
#include <stdio.h>
int main(void) {
double cake_amount = 0.33;
int age = 26;
char my_last_initial = 'H';
printf("Henry is %d and is about to eat %lf cakes\n", age, cake_amount);
printf("The character %c has an ASCII value of %d!\n", my_last_initial, my_last_initial);
return 0;
}
#include <stdio.h>
int main(void) {
int first_nuumber = 12;
int second_number = 5;
printf("%d\n", first_nuumber/second_number);
return 0;
}