Tuesday, December 18, 2012

CONVERT A STRING TO UPPERCASE IN C++


#include<iostream.h>
#include<ctype.h>
#include<string.h>
void main()
{
char str[50];
int flag=1;
cout<<"\nENTER A STRING : \n\n";
cin.getline(str,50);
for(int i=0; str[i]!='\0';i++)
{
if(islower(str[i]))
{
flag=1;
str[i]=toupper(str[i]);
}
}
if((flag==1)||(str[i]=='\0'))
{
cout<<"\nUPPERCASE STRING IS :\n\n";
cout<<str;
}
}

No comments: