Skip to content

Instantly share code, notes, and snippets.

@sojohnnysaid
Created January 6, 2018 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sojohnnysaid/c0b75eac6b7c2031977129f148b7015a to your computer and use it in GitHub Desktop.
Save sojohnnysaid/c0b75eac6b7c2031977129f148b7015a to your computer and use it in GitHub Desktop.
// 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