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

Popular posts from this blog

AI and Human Evolution

Snake Game using JAVA

To Do List App (GUI) using C#