How to Print alternate characters of strings in c

C program to display alternate characters from string based on n value .

This program will also help you to splitting of a string and display the lowercase and uppercase alphabets. 

#include<stdio.h>

#include <stdlib.h>

int main()

{

    char s[1000],a[1000],b[1000];

    scanf("%s",s);

    int n,m,j=0,k=0,count=0,x=0,y=0,i;

    scanf("%d",&n);

    m=strlen(s);

    for(i=0;i<m;i++)

    {

        if(s[i]>='a'&&s[i]<='z')

        a[j++]=s[i];

        if(s[i]>='A'&&s[i]<='Z')

        b[k++]=s[i];

    }

    for(i=0;i<n;i++)

    {

        printf("%c%c",a[i],b[i]);

    }

}

Input

abAdCplaNE

2


Output

aAbC


Input 2

cRICkEt

3


Output 2

cRkItC

Rajesh

This Blog will help you to find out the c programs solution easily and also you can able to understand the program.Please follow our blog for more useful updates.

Post a Comment (0)
Previous Post Next Post