You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include <iostream> #include <string.h> #include <ctype.h> using namespace std; int main() { char string[100], word[20], max[20], min[20], c; int i = 0, j = 0, flag = 0; cout<<"Enter string: "; cin.getline(string,100); for (i = 0; i < strlen(string); i++) { while (i < strlen(string) && !isspace(string[i]) && isalnum(string[i])) { word[j++] = string[i++]; } if (j != 0) { word[j] = '\0'; if (flag==0) { flag = 1; strcpy(max, word); strcpy(min, word); } if (strlen(word) > strlen(max)) { strcpy(max, word); } if (strlen(word) < strlen(min)) { strcpy(min, word); } j = 0; } } cout<<"The largest word is '"<<max <<"' and smallest word is '"<<min<<"' in ''"<<string<<"'"; return 0; }