C examples for Language Basics:scanf
Read year from user and convert to integer
#include <stdio.h> #include <stdlib.h> int main()/*www .ja v a 2s .co m*/ { int methus; int you; char years[8]; printf("How old are you?"); gets_s(years); you=atoi(years); printf("How old was Jame?"); gets_s(years); methus=atoi(years); printf("You are %d years old.\n",you); printf("James was %d years old.\n",methus); return(0); }