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.

Need help with a C homework

0 votes
asked Apr 18, 2020 by Iftiaq (620 points)
Delete the even-numbered characters in the character string pointed to by s, and place the new string formed by the remaining characters in the string in the index group of t. For example, when the content in the string referred to by s is: "ABCDEFGHIJK", the content in the index group at t should be: "BDFHJ".

1 Answer

+2 votes
answered Apr 20, 2020 by BionicBeaver (480 points)
selected Apr 21, 2020 by Iftiaq
 
Best answer
#include <stdio.h>
#include <string.h>
int main() 
{
    char string[100], odd[100], i, k;
    i = k = 0;
    printf("Enter your input string:");
    fgets(string, 100, stdin);
    string[strlen(string) - 1] = '\0';
    printf("Given Input string:%s\n", string);
    while (string[i] != '\0') 
    {
        if(i % 2 != 0) 
        {
            odd[k++] = string[i];
        }
        i++;
    }
    odd[k] = '\0';
    printf("Characters at odd position: %s\n", odd);
    return 0;
}
Do you mean something like this?
commented Apr 21, 2020 by Iftiaq (620 points)
Yes, thank you!
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.
...