C Programming Tutorial – 8 – Get data from keyboard scanf():

Note:

  • // scanf() :  get data from keyboard or user.
  • // Use & before all of the variables, except Array variables.

Code:
—————————

#include <stdio.h>
#include <stdlib.h>

int main()
{

char firstname[20];
char lovename[20];
int NumberOfBaby;
printf(“What is your name?\a\n”);
scanf(“%s”,firstname);                                                           // scanf get data from keyboard or user
printf(“What is your love name?\a\n”);
scanf(“%s”,lovename);
printf(“How many baby you will have?\a\n”);
scanf(“%d”, &NumberOfBaby);                     // Use & before all of the variables except Array variables.
printf(“%s and %s are in love. They will have %d babies\n”, firstname,lovename ,NumberOfBaby );

return 0;

}