I/O Operations Q. 5: Upper case conversion

QUESTION DESCRIPTION 

Kamal is struggling to convert the characters of given string to upper case.

Help Kamal to convert the given string to upper case.Refer the following sample test cases.






#include <iostream>
using namespace std;
void upper_string(string str)
{
  for(int i=0;str[i]!='\0';i++)
  {
  if(str[i] >= 'a' && str[i] <= 'z')
    str[i]=str[i]-32;
  }
cout<<str;
}
int main()
{
  string str;
  getline(cin,str);
  upper_string(str);

return 0;

}

Comments

Popular Posts