write a program in bluej to input a string and convert into upper case and display count of consecutive characters
Answers
Answered by
1
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;
}
Answered by
1
Attachments:
Similar questions
Math,
4 months ago
Business Studies,
4 months ago
Chemistry,
4 months ago
History,
1 year ago
Math,
1 year ago