Last active
January 19, 2021 22:49
-
-
Save sojohnnysaid/619fdfb586960b8f0009d8b7afb3e150 to your computer and use it in GitHub Desktop.
Example of how variables work in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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