Advertisement
nasdevs

mencari huruf awal & akhir suatu kata/kalimat

Nov 12th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int kalimatAkhir;
  6.     string kalimat;
  7.     cout << "Masukkan kalimat : "; getline(cin, kalimat);
  8.     kalimatAkhir = kalimat.length();
  9.     cout << "\nHuruf pertama : " << kalimat[0];
  10.     cout << "\nHuruf terakhir : " << kalimat[kalimatAkhir-1];
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement