Example of how variables work in C
#include<stdio.h> | |
int main(void){ | |
// Example of using variables to hold data | |
int number = 90; | |
char string[] = "That is a great score"; | |
char letter = 'A'; | |
printf("Your score was %d%%! %s! You're an %c student!\n\n", number, string, letter); | |
printf("Putting some new data in our variables...\n\n"); | |
number = 80; | |
// Array's are immutable (even if the exact same string!) | |
// this line of code will cause errors in compilation | |
// string = "That is a great score"; | |
char new_string[] = "That is a pretty good score"; | |
letter = 'B'; | |
printf("Your score was %d%%! %s! You're a %c student!\n\n", number, new_string, letter); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment