Program to reverse an entered alphabet

12 months ago Admin 0

Reverse an entered alphabet

This article illustrates the concept how to reverse an entered alphabet in c/c++.

reverse an entered alphabet

Here is the source code and output of both the programs.

C Programming language

Program


#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
 char alpha;
 clrscr();
 printf("Enter an alphabet:- ");
 alpha=getchar();
 printf("Reverse case of enter Alphabet is:- ");
 if(islower(alpha))
  {
   putchar(toupper(alpha));
  }else{
   putchar(tolower(alpha));
  }
getch();
}

After successfully compiling and executing the above C program,output is:-

reverse an entered alphabet


C++ Programming language

Program


#include<iostream.h>
#include<conio.h>
#include<ctype.h>
#include<stdio.h>
void main()
{
 clrscr();
 char alpha;
 cout<<"Enter an alphabet:- ";
 alpha=getchar();
 cout<<"Reverse case of enter Alphabet is:- ";
 if(islower(alpha))
  {
   putchar(toupper(alpha));
  }else{
   putchar(tolower(alpha));
  }
getch();
}

After successfully compiling and executing the above C++ program,output is:-

reverse an entered alphabet


Comment below if you are facing any problem or you find any error in the above program and also subscribe to our newsletter for more updates.


Read more c/c++ Programs published by snapcout:-

Program to reverse the string
Program to remove spaces from given string
Program to sort a string in alphabetic order
Program to swap two strings
Program to convert string into lower case without using strlwr()


About article

Written By:- Admin

Published on:- 9/09/2018

Published By:- Snapcout


Don't forget to share the article if you like it:-