Answer to Question #173071 in C++ for Vimal D

Question #173071

Develop a C++ program for the person who wrongly filled the online application and help him to convert the input string to lowercase and uppercase.


1
Expert's answer
2021-03-18T13:52:26-0400
#include <iostream>
using namespace std;

void lower_string(string str)
{
  for(int i=0;str[i]!='\0';i++)
  {
    if (str[i] >= 'A' && str[i] <= 'Z')  
      str[i] = str[i] + 32;        
  }
  cout<<"\n The string in lower case: "<< str;
}

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<<"\n The string in upper case: "<< str;
}

int main()
{
  string str;
    cout<<"Enter the string ";
    getline(cin,str);
    lower_string(str);  
  upper_string(str);  
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS