Skip to content

Instantly share code, notes, and snippets.

@DeclanGas
Created June 23, 2022 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeclanGas/956b1c8741af47134ff56b1bc7695531 to your computer and use it in GitHub Desktop.
Save DeclanGas/956b1c8741af47134ff56b1bc7695531 to your computer and use it in GitHub Desktop.
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// declare a string named "name" and get input with get_string
string name = get_string("Enter Name: ");
// declare an int named "age" and get user input with get_int
int age = get_int("Enter Age: ");
// declare a float named "gpa" and use get_float to enter a number with a decimal
float gpa = get_float("Gpa: ");
// declare long named "student_id" and use get_long for input
long student_id = get_long("Student Id: ");
// declare a double named "pi" and use get_double to accept user input to 10 decimal placees
double pi = get_double("Enter Pi to 10 decimal places: ");
// prints a blank line followed by each input value
printf("\n");
printf("Hello %s, here is the data you entered...\n", name);
printf("Student ID: %ld\n", student_id);
printf("Age: %i\n", age);
printf("GPA: %.1f\n", gpa);
printf("The value of pi is %.10f\n", pi);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment