Hey all,
So I'm trying to write a program that takes a 5 letter word and displays it as a palindrome with a space between each letter. I can do this in only 11 lines of code, however I need a function part to the program and I'm not sure what this function should do or how to modify my code to fix it? This is what I have so far.
Code:
#include <stdio.h>
#include <stdlib.h>
char palindrome(char word);
char main(void)
{
char palin;
char letter0, letter1, letter2, letter3, letter4;
printf("What is the five letter word? ");
scanf("%c",&letter0);
scanf("%c",&letter1);
scanf("%c",&letter2);
scanf("%c",&letter3);
scanf("%c",&letter4);
palin = palindrome(letter0, letter1, letter2, letter3, letter4);
printf("Here is the palindrome:\n", palin);
return 0;
}
char palindrome(char word)
{
char letter0, letter1, letter2, letter3, letter4;
char pDrome[50];
pDrome == printf("%c %c %c %c %c %c %c %c %c", letter0, letter1, letter2, letter3, letter4, letter3, letter2, letter1, letter0);
return pDrome;
}