w3resource logo

:

C Programming Exercises

C Exercises: Print characters in a reverse way

C Basic Declarations and Expressions: Exercise-4 with Solution

Write a C program to print the following characters in a reverse way.
Test Characters : 'X', 'M', 'L'

C Code:

#include <stdio.h> 
 int main() 
 {
    char char1 = 'X';
    char char2 = 'M';
    char char3 = 'L';

	printf("%The reverse of %c%c%c is %c%c%c\n",
		char1, char2, char3,
		char3, char2, char1);

	return(0);
}

Sample Output:

The reverse of XML is LMX

Solution

Improve this sample solution and post your code through Disqus