Write a program named as reverse.c that reads a message, then prints the reversal of the message. The output of the program should look like this: Enter a message: Don ’t get mad, get even. Reversal is : .neve teg ,dam teg t ’noD Hint: Read the message one character at a time (using getchar) and store the characters in an array. Stop Reading when the array is full or the character read is ‘\n’. The framework of reverse.c is as below: /* reverse.c */ #include #define N 50 int main(){ int arr[N],i=0; char ch; printf("Enter a message: "); /* Put code here to get input from user by using getchar() */ printf("Reversal is: "); /* Put code here to print out the reversal by using putchar()*/ printf("\n"); return 0; }
Write a
Enter a message: Don ’t get mad, get even. Reversal is : .neve teg ,dam teg t ’noD
Hint: Read the message one character at a time (using getchar) and store the characters in an array. Stop Reading when the array is full or the character read is ‘\n’.
The framework of reverse.c is as below:
/* reverse.c */ #include #define N 50 int main(){ int arr[N],i=0; char ch; printf("Enter a message: "); /* Put code here to get input from user by using getchar() */ printf("Reversal is: "); /* Put code here to print out the reversal by using putchar()*/ printf("\n"); return 0; }
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 2 images