tell the user to enter an element, take the input as a string variable. Convert
ID: 3762613 • Letter: T
Question
tell the user to enter an element, take the input as a string variable.
Convert the string to all lower case letters except for the first letter which should be converted to upper case. For example, if the user enters copper, COPPER, or CoPpEr, it should be converted to Copper.
and out put the element with correct capitalization.
only use these libraries
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <fstream>
Explanation / Answer
#include <iostream>
using namespace std;
int main() {
char in[255], out[255];
cout<<"Enter a string: ";
cin>>in;
int i=0;
out[i] = toupper(in[i]);
i++;
while(in[i]!='') {
out[i]=tolower(in[i]);
i++;
}
in[i]='';
cout<<"Output: "<<out;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.