Menu BAR

FEEL FREE TO ASK ANY PROGRAM and please mention any error if you find it

18 Apr 2013

PROGRAM TO CONVERT CHARACTERS FROM LOWERCASE TO UPPERCASE AND FROM UPPERCASE TO LOWERCASE IN GIVEN STRING IN C++

Write a program to convert all characters from lowercase to uppercase and all upper case characters to lowercase in given string


#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int m,t=0,i;
 char a[100];
 cout<<"Enter the string\n";
 cin.getline(a,100);
 for(i=0;a[i]!='\0';i++)  //to count total number of words include space
 {
  t++;
 }
 cout<<"\nString after conversion\n";
 for(i=0;i<t;i++)
 {
  m=0;
  m=a[i];
  if(m>=65&&m<=90)
  {
   m=m+32;
   cout<<char(m);
  }
  else
   if(m>=97&&m<=122)
   {
    m=m-32;
    cout<<char(m);
   }
   else
    {
     cout<<char(m);
    }
  }
 getch();
}
==OUTPUT==

No comments:

Post a Comment