1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
qwelly [4]
3 years ago
12

Given a string, convert the characters of the string into opposite case,i.e. if a character is lower case than convert it into u

pper case and vice versa.
Examples:

Input : geeksForgEeks
Output : GEEKSfORGeEKS

Input : hello every one
Output : HELLO EVERY ONE
Recommended: Please try your approach on {IDE} first, before moving on to the solution.
ASCII values of alphabets: A – Z = 65 to 90, a – z = 97 to 122
Steps:

Take one string of any length and calculate its length.
Scan string character by character and keep checking the index .
If character in a index is in lower case, then subtract 32 to convert it in upper case, else add 32 to convert it in upper case
Print the final string.
Computers and Technology
1 answer:
o-na [289]3 years ago
8 0

Answer:

// CPP program to Convert characters  

// of a string to opposite case  

#include<iostream>  

using namespace std;  

// Function to convert characters  

// of a string to opposite case  

void convertOpposite(string &str)  

{  

int ln = str.length();  

 

// Conversion according to ASCII values  

for (int i=0; i<ln; i++)  

{  

 if (str[i]>='a' && str[i]<='z')  

 //Convert lowercase to uppercase  

  str[i] = str[i] - 32;  

 else if(str[i]>='A' && str[i]<='Z')  

 //Convert uppercase to lowercase  

  str[i] = str[i] + 32;  

}  

}  

// Driver function  

int main()  

{  

string str = "GeEkSfOrGeEkS";  

 

// Calling the Function  

convertOpposite(str);  

 

cout << str;  

return 0;  

}  

Explanation:

You might be interested in
System A has two processors. Program X takes 50 seconds to execute on one of the processors. Program Y takes 50 seconds to execu
777dan777 [17]

Answer:

I will pick system A

Explanation:

System A has dual processor and it will concurrently run the two program(X and Y) in 50 seconds, with program X on the first processor and program Y on the second one while system B will take 70 seconds to run the two program since it runs on a single processor, it will run program X first and then program Y next, summing up to 70 seconds. so therefore I will pick system A since I'm  considering the system throughput.

5 0
4 years ago
How many fonts are there in a theme?<br> A. 1<br> B. 2<br> C. 4<br> D. 5
BlackZzzverrR [31]

B. 2

If incorrect, sorry

6 0
3 years ago
What file name would allow you to easily find and edit your document later in Word Online?
DIA [1.3K]
The first one “ jane_essay 2_24_21 “
6 0
3 years ago
Read 2 more answers
A good machine should have the mechanical advantage of......?​
zavuch27 [327]

Answer:

The ideal mechanical advantage (IMA) of an inclined plane is the length of the incline divided by the vertical rise, the so-called run-to-rise ratio. The mechanical advantage increases as the slope of the incline decreases, but then the load will have to be moved a greater distance.

Explanation:

4 0
3 years ago
Formatting can be applied to
valkas [14]
Formatting can maybe be applied to software works
8 0
3 years ago
Read 2 more answers
Other questions:
  • How do all apple phones work?
    7·1 answer
  • Write down the complete procedure for creating ExcelSheet.
    8·1 answer
  • Given a int variable named calls Received and another int variable named operators On Call write the necessary code to read valu
    14·1 answer
  • Choose all that apply.
    6·2 answers
  • What is the difference between primary storage, secondary storage and off-line storage?
    5·1 answer
  • Which of these practices should you follow while creating your resume?
    13·2 answers
  • What is distribution hardware?
    14·1 answer
  • Types of computer that we use in our daily life​
    13·2 answers
  • In the negative side of the battery, there are millions and millions of _________.
    14·1 answer
  • What is the importance of charts and graphics in providing<br> information?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!