C examples for Language Basics:scanf
Asks for your name and then your favorite color. Use printf() statement then displays what you enter.
#include <stdio.h> int main()/*from w ww . ja va 2s . co m*/ { char name[20]; char color[20]; printf("What is your name?"); scanf("%s",name); printf("What is your favorite color?"); scanf("%s",color); printf("%s's favorite color is %s\n",name,color); return(0); }