Code

darpan.kattel

Darpan Kattel

• Jan. 1, 2022, 6:12 p.m.

WAP in C to find the largest word in a sentence?

Question From IOE 2075 Regular Ashwin. I found this too hard yet satisfying!

C

#include
#include
int main(){
    char getString[200], present_str[200];
    static char greatest[200];
    int i = 0j = 0;
    printf("Enter any sentence:\n");
    gets(getString);
    while (1)
    {
        if ((getString[i]== ' ') || (getString[i]== '\0'))
        {
            present_str[j] = '\0';
            if (strlen(greatest)<strlen(present_str))
            {
                strcpy(greatestpresent_str);
            }
            if (getString[i]=='\0')
            {
                break;
            }
            j = 0;
            i++;
            continue;
        }
        present_str[j]=getString[i];
        j++;
        i++;
    }
    printf("The largest word is '%s'"greatest);
    return 0;
}
Output:
WAP in C to find the largest word in a sentence? | Output of C Language Code

Add comment:

Total 0 comments