Wednesday, April 9, 2014

Change case of character

Q. Write a C program to accept a character from user and convert it opposite case.

For example, if user enter character d then it is will convert in upper-case D.

Ans.

/*c program to convert character upper-case to lower case and vice verse*/
#include<stdio.h>
#include<conio.h>
int main()
{
 char ch;
 printf("Enter any character : ");
 scanf("%ch", &ch);
 if(ch>=A && ch<=Z)
     ch=ch+32;
 else if(ch>a && ch<=z)
     ch=ch-32;
 printf("Convert case of character : %c",ch);
 getch();
 return 0;
}

/*****************Output******************/

Output for change case of entered character C program
Screen shot for change case of entered character by user


Related Programs:
  1. How to identify what is entered by user
  2. How to identify case of character
  3. Read and print string

Related Posts by Categories

0 comments:

Post a Comment