Hi all,
I have been working on a quesstion, i have solved parts a up to c, but im having trouble with part d and e, any tips on how i can solve them would be very much appreaciated. I'd also appreaciate if you guys can also tell me if i have correctly solved a,b and c.
this is the question:
If string s1 and string s2 are two string variables, containing some strings how do you:
a.print out the number of characters of s1 to the screen
answer:
b.concatenate s1 and s2 and store the result in another string s
answer:
c.determine whether s2 contains the string "cool"
answer:
d.display the string s1 in reverse order on the screen
e.display the lower-case version of the string s2 to the screen (Hint: you may want to create a separate function to return the lower-case version of a single character and use that function to solve this problem).
Thanks in advanance,
carly
I have been working on a quesstion, i have solved parts a up to c, but im having trouble with part d and e, any tips on how i can solve them would be very much appreaciated. I'd also appreaciate if you guys can also tell me if i have correctly solved a,b and c.
this is the question:
If string s1 and string s2 are two string variables, containing some strings how do you:
a.print out the number of characters of s1 to the screen
answer:
Code:
string s1= “Easy” cout<<s1.length()<<endl;
answer:
Code:
string s = s1+s2;
answer:
Code:
string s2("CSCI204 is cool"); int where = s2.find("cool"); cout << "First occurence of cool was found at: " << where << endl;
d.display the string s1 in reverse order on the screen
e.display the lower-case version of the string s2 to the screen (Hint: you may want to create a separate function to return the lower-case version of a single character and use that function to solve this problem).
Thanks in advanance,
carly
Comment