To remove characters in string without including alphabets

Question:
Write a program to remove characters in the string without including alphabets.
Logic:
- Get the input string from the user by including symbols.
- Checks for non-alphabets in the string and removes it.
- Then prints the remaining characters.
Algorithm:
- Get the input string from the user.
- Then check the individual characters in the string for non-alphabets.
- And removes the character in the string using swapping.
- Then print the remaining characters in the string.
Program:
[code lang=”c”]
#include<stdio.h>
void main()
{
char a[100];
int i,j,n;
clrscr();
printf("enter the string:");
gets(a);
n=strlen(a);
for(i=0;i<n;i++)
{
if((a[i]>65&&a[i]<91)||(a[i]>96&&a[i]<123))//checks for the alphabet
{
continue;
}
else
{
for(j=i;j<n;j++)//removes the character other than alphabet
{
a[j]=a[j+1];
}n–;//after removing decrementing the length
}
}
printf("string after removing characters:");
puts(a);//prints the string
getch();
}
[/code]