Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Example of how to include the standard IO library in order to use
// common functions that allow input and output from the terminal
#include <stdio.h> // Include directive gives us access to the .h file
int main(void){
char character = 'A';
char string[] = "Hello World";
int number = 42;
float my_float = 20.20;
// example of format specifiers used for different data types
printf("Character:\t%c\n", character);
printf("Character Code:\t%d\n", character);//changes the format specifier to %d
printf("String:\t%s\n", string);
printf("Number:\t%d\n", number);
printf("Float:\t%.5f\n", my_float); // using .5 gives us 5 decimal places
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment