CPP   91
strings arrays 3
Guest on 20th April 2022 02:07:13 AM


  1. // For C++ libraries.
  2. #include <iostream>
  3. // Library for strings.
  4. #include<string>
  5. using namespace std;
  6.  
  7. int main() {
  8.     string word="racecar";
  9.     string fruit1="apple";
  10.     string fruit2="pear";
  11.  
  12.     cout << word.substr(0,4) << endl;
  13.     cout << word.substr(4,3) << endl;
  14.  
  15.     if(fruit1<=fruit2)
  16.         cout << fruit1 << " " << fruit2 << endl;
  17.  
  18.     if(fruit1>fruit2)
  19.         cout << fruit2 << " " << fruit1 << endl;
  20.  
  21.     return 0;
  22.  
  23. }

Raw Paste

Login or Register to edit or fork this paste. It's free.