C examples for Language Basics:scanf
Write a program that asks for your first name, your last name, and then prints the names in the format last, first
#include <stdio.h> int main(void) { /* w w w . j a v a2 s. c o m*/ char fname[40]; char lname[40]; printf("Enter your first name: "); scanf("%s", fname); printf("Enter your last name: "); scanf("%s", lname); printf("%s, %s\n", lname, fname); return 0; }