Wednesday, 6 February 2019

Print Only Alphabets

A string S is passed as the input. S can contain alphabets, numbers and special characters. The program must print only the alphabets in S.

Input Format:
The first line contains S.

Output Format:
The first line contains only the alphabets in S.

Boundary Conditions:
The length of the input string is between 1 to 1000.

Example Input/Output 1:
Input:
abcd_5ef8!xyz
Output:
abcdefxyz

Program
#include <stdio.h>

int main()
{
    char S[1000];
    int i=0;
    
    scanf("%[^\t\n]s",S);
    
    while (S[i]!='\0' && S[i]!='\n')
    {
        if ((S[i]>='A' && S[i]<='Z') || (S[i]>='a' && S[i]<='z'))
        printf("%c",S[i]);
        ++i;
    }

    return 0;
}


Output:
Input:
jhjkhj564564   jk j|dg

jhjkhjjkjdg