- // For C++ libraries.
- #include <iostream>
- // Library for strings.
- #include<string>
- using namespace std;
- int main() {
- string word="racecar";
- string fruit1="apple";
- string fruit2="pear";
- cout << word.substr(0,4) << endl;
- cout << word.substr(4,3) << endl;
- if(fruit1<=fruit2)
- cout << fruit1 << " " << fruit2 << endl;
- if(fruit1>fruit2)
- cout << fruit2 << " " << fruit1 << endl;
- return 0;
- }
Raw Paste