Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- string word[20];
- string longest;
- cout << "How many words do you wish to check: ";
- int n;
- cin >> n;
- for (int i = 0; i < n;i++) {
- cout << "Enter a word: "<<endl;
- cin >> word[i];
- int min = 1;
- if (word[i].length() > min) {
- min = word[i].length();
- longest = word[i];
- }
- }
- cout << "Longest word is: "<<longest;
- }
Advertisement
Add Comment
Please, Sign In to add comment