program to change a character and replace it using c programming language
// program to change a letter from user inputted word
#include<stdio.h>
#include<string.h>
int main(){
char userInput[100];
char word;
char change;
int length;
printf("enter a word:");
scanf(" %s", userInput);
printf("enter the letter you want to change.\n:-");
scanf(" %c", &change);
printf("enter replacement:");
scanf(" %c", &word);
length = strlen(userInput);
for(int i = 0; i <= length; i++){
for(int j = 0; j < length; j++){
if(userInput[j]==change){
userInput[j] = word;
break;
}
}
}
printf(" %s", userInput);
}
Comments
Post a Comment