write a c program that accepts a name as first name last name but displays the name as last name first name in the output

Sure! Here's a C program that accepts a name as "first name last name" and displays the name as "last name, first name":

```c
#include <stdio.h>
#include <string.h>

int main() {
char firstName[50];
char lastName[50];

// Accept the name as "first name last name"
printf("Enter the name (first name last name): ");
scanf("%s %s", firstName, lastName);

// Display the name as "last name, first name"
printf("Output: %s, %s\n", lastName, firstName);

return 0;
}
```

To explain the code:

1. We include the necessary header files: `stdio.h` for input/output functions, and `string.h` for string handling functions.
2. In the `main()` function, we declare two character arrays: `firstName` and `lastName`, each with a maximum size of 50 characters to store the first and last name respectively.
3. We prompt the user to enter the name as "first name last name" using the `printf()` function.
4. We use the `scanf()` function to read the name from the user, where `%s` is used to read a string (terminated by a whitespace character).
5. Finally, we use the `printf()` function to display the name as "last name, first name" using the format specifier `%s`.

After running the program, you can enter the name as "first name last name", and it will display the name in the desired format as "last name, first name" in the output.