C program to remove an element 'e' from a string
Code :
Output:
Enter a string hello
hllo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
void main() | |
{ | |
char arr[20]; | |
int i,j; | |
printf("\nEnter a string :"); | |
scanf("%s",arr); | |
for(i=0;arr[i]!='\0';i++) | |
{ | |
if(arr[i]=='e') | |
{ | |
for(j=i;arr[j]!='\0';j++) | |
{ | |
arr[j]=arr[j+1]; | |
} | |
} | |
} | |
printf("\n%s",arr); | |
} |
Output:
Enter a string hello
hllo
Comments
Post a Comment
Feel free to leave a comment...