[Solved] Can someone help me to do this exercise [closed]


enter image description here

Used this code to obtain that output

#include <stdio.h>
#include <string.h>

int main(void) {
    char text[1024];
    int biggest = 0, newBiggest = 0, stopCondition = 0, phrase = 0;

    puts("Enter text, end with #");

    do
    {
        scanf(" %[^\n]s", text);
        for(int i = 0; i < strlen(text); i++)
        {
            if (text[i] == '#')
            {
                stopCondition = 1;
                break;
            }
        
            if (text[i] == ' ' || text[i] == ',' || text[i] == '.' || text[i] == '!' || text[i] == '\n' || text[i] == '?')
            {
                if (newBiggest > biggest)
                    biggest = newBiggest;
                newBiggest = 0;
            }
            else
                newBiggest++;


            if (text[i] == '.' || text[i] == '!' || text[i] == '\n' || text[i] == '?')
            {
                printf("In phrase %d biggest word found have %d chars!\n",++phrase,biggest);
                newBiggest = 0;
                biggest = 0;
            }
        }
    }while(!stopCondition);

    return 0;
}

To obtain the global biggest word and in witch pharase it apear i let it as a challange for you, if you struggle doing that let me know and i give you some tips.

//——————————————————————————————————————————–\\

Changes you need to do acording new specifications:
enter image description here

#include <stdio.h>

int main(void) {
    char c;
    int biggest = 0, newBiggest = 0, stopCondition = 0, phrase = 0;

    puts("Enter text, end with #");

    do
    {
        c = getchar();
        if (c == '#')
        {
            stopCondition = 1;
            break;
        }
    
        if (c == ' ' || c == ',' || c == '.' || c == '!' || c == '\n' || c == '?')
        {
            if (newBiggest > biggest)
                biggest = newBiggest;
            newBiggest = 0;
        }
        else
            newBiggest++;


        if (c == '.' || c == '!' || c == '?')
        {
            printf("In phrase %d biggest word found have %d chars!\n",++phrase,biggest);
            newBiggest = 0;
            biggest = 0;
        }
    }while(!stopCondition);

    return 0;
}

1

solved Can someone help me to do this exercise [closed]