Monday, May 5, 2008

program to convert uppercase to lowercase and vice versa

Write a program that will ask the user to enter his/her name. Convert all uppercase letter to lowercase letter and vice-versa.

PROGRAM:

#include <iostream.h>

#include <conio.h>

#include <stdio.h>

#include <ctype.h>

#include <string.h>


void main() {

clrscr();

int len,chr;

char ch[50];

cout<<"Program to conver lowercase to uppercase and uppercase to lowercase:\n";

cout<<"Enter Your Name: ";

gets(ch);

len=strlen(ch);

for(int i=0;i<len;i++) {

chr = ch[i];

if(isupper(chr))

chr = tolower(chr);

else

chr = toupper(chr);

putchar(chr);

}

getch();

}//end of the program

No comments: