Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

example :i am the student, user want to delete the word which size is 2 so output will be: i the student.

+1 vote
asked Jan 25, 2020 by anonymous
#include<stdio.h>

#include<string.h>

void main()

{

            char a[100],x[100];

            int j, i, k,c,l;

            j = c = l = i = k = 0;

printf("Enter the string:");

            gets(a);

int b=0;

            int n = strlen(a);

            printf("n is %d\n",n);

printf("Enter the number:");

scanf("%d",&b);

aa:

       

                i=j;

                while(a[i] != ' ' && i<n)

                {

                    l=i;

                    i++;

                }
                for (k = j; k < l; i++)

                {
                   c++;
               }

                if (c != b)

                {
                    for (k = j; k < l; k++)

                    {

                        x[k] = a[j];

j++;

                    }

                    j = l + 1;

                }

                else {
                    j = l + 1;}
            goto aa;

puts(x);

}

1 Answer

0 votes
answered Jul 4, 2023 by Bhargav Sai (140 points)
#include<stdio.h>

int main()
{
    char a[100], b[100];
    int i=0, c=0,s=0,k=0;
    
    printf("Enter String: ");
    scanf("%[^\n]s", a);  // scans until the new line
    
    do
    {
        if(a[i] != ' ' && a[i+1] != '\0')
            c++;                                    // counts the length of substring
        else
        {
            if(a[i+1] == '\0')
                c++;
            if(c != 2)
            {
                while(s<=i)
                    b[k++] = a[s++];
            }

            s = i+1;
            c=0;
        }
        i++;
    }while(a[i] != '\0');
    
    b[k] = '\0';
    printf("%s", b);
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...