Write a program that reads a person's first and last names separated by a space, assuming the first and last names are both single words. Then the program outputs last name, first name. End with newline.

Example output if the input is: Maya Jones

code in C language

Respuesta :

Following are the code to input string value in C Language.

Program Explanation:

  • Defining header file.
  • Defining the main method.
  • Inside the method, two char array "lname, fname" is declared, which inputs value from the user-end.
  • After input value, a print method is declared that prints the last name with ","  and first name.

Program:

#include <stdio.h>//header file

int main()//defining main method

{

char lname[15],fname[15];//defining two char array

scanf("%s%s",fname, lname);//use input method that takes string value in it  

printf("%s , %s",lname,fname);//use print method that prints string value

return 0;

}

Output:

Please find the attached file.

Learn more:

brainly.com/question/14436979

Ver imagen codiepienagoya