Wednesday, May 6, 2020

alternate digit

Remove alternate digits program in C

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

int main()
{
    int input = 0;
    int len = 0;
    int i = 0;
    char sinput[64] = {0, };

    printf("Enter the number :");
    scanf("%d", &input);
    sprintf(sinput, "%d", input);
    len = strlen(sinput);

    printf("Output : ");
    for (i = 0; i < len; i+=2)
    {
        printf("%c\t", sinput[i]);
    }
    printf("\n");
    return 0;
}

No comments:

Post a Comment