Asks for your name and then your favorite color. Use printf() statement then displays what you enter. - C Language Basics

C examples for Language Basics:scanf

Description

Asks for your name and then your favorite color. Use printf() statement then displays what you enter.

Demo Code

#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);
}

Result


Related Tutorials