Run
#include <stdio.h>
int main()
{
//Initializing variable.
char str[100];
int i, j;
//Accepting input.
printf(" Enter a string : ");
gets(str);
//Iterating each character and removing non alphabetical characters.
for(i = 0; str[i] != '\0'; ++i)
{
while (!( (str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z') || str[i] == '\0') )
{
for(j = i; str[j] != '\0'; ++j)
{
str[j] = str[j+1];
}
str[j] = '\0';
}
}
//Printing output.
printf(" After removing non alphabetical characters the string is :");
puts(str);
return 0;
}
Output:
Enter a string : *1prep_insta*
After removing non alphabetical characters the string is :prepinsta
#include
#include
int main()
{
int i,j=0,l;
char str[100],cpy[100];
printf(“string?”);
scanf(“%s”,&str);
l=strlen(str);
for(i=0;i=’a’&&str[i]=’A’&&str[i]<='Z')
{ cpy[j]=str[i];
j++;
}
}
printf("%s",cpy);
}