All pastes #78560 Raw Edit

Something

public text v1 · immutable
·published 2006-07-04 07:38 UTC
rendered paste body
#include <stdio.h>
main()
{
  int age;
  char weight[4];
  char first[15], last[15];  /* 2 char arrays */

  printf("\nWhat is your first name? ");
  scanf(" %s", first);   /* No ampersand on char arrays */
  printf("What is your last name? ");
  scanf(" %s", last);

  printf("How old are you? ");
  scanf(" %d", &age);     /* Ampersand required */
  printf("How much do you weigh? ");
  scanf(" %s", &weight);  /* Ampersand required */

  printf("\nHere is the information you entered;\n");
  /* Notice the space between the following printf()'s
     two %s occurrences to ensure that the first
     and last names are separated. */
  printf("Name: %s %s\n", first, last);
  printf("Age: %d\nWeight: %s", age, weight);
  getch ();
  return 0;  /* Always best to do this */
}