Write a program that asks for your first name, your last name, and then prints the names in the format last, first - C Language Basics

C examples for Language Basics:scanf

Description

Write a program that asks for your first name, your last name, and then prints the names in the format last, first

Demo Code

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

Result


Related Tutorials