Skip to content

Instantly share code, notes, and snippets.

@s3f
Created December 29, 2016 22:45
Show Gist options
  • Save s3f/b38b42294ec9c45fdb229410eab17b2b to your computer and use it in GitHub Desktop.
Save s3f/b38b42294ec9c45fdb229410eab17b2b to your computer and use it in GitHub Desktop.
Chapter 8 - Getting User Input created by s3f - https://repl.it/EcYQ/3
// This sample program asks a user for some basic data and prints it on the screen in order to show what was entered.
#include <stdio.h>
main()
{
char firstInitial;
char lastInitial;
int age;
int favorite_number;
printf("What letter does your first name begin with?\n");
scanf(" %c", &firstInitial);
printf("What letter does your last name begin with?\n");
scanf(" %c", &lastInitial);
printf("How old are you?\n");
scanf(" %d", &age);
printf("What is your favorite number(Integer only)?\n");
scanf(" %d", &favorite_number);
printf("\nYour initials are %c.%c. and you are %d years old", firstInitial, lastInitial, age);
printf("\nYour favorite number is %d.\n\n", favorite_number);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment