Display alternate characters in string - C

Write a C program to read string from user and display alternate characters.

Solution:

#include<stdio.h>
#include<string.h>
int main()
{
    char str[20];
    int i=0;
    printf("Enter String: ");
    scanf("%s",str);
    printf("\nString With Alternate Character Displayed:  ");
    for(i=0;i<strlen(str);i=i+2)
    {
        printf("%c",str[i]);
    }
    return 0;
}


Output:

display alternate character