1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vova2212 [387]
3 years ago
11

Write a program to check if two strings are different by one and only one character (when checked character by character). For e

xample, lake and bake are different by one and only one character. pal and pale, bus and bit, kite and bit are NOT different by one and only one character.
Computers and Technology
1 answer:
Elis [28]3 years ago
6 0

<u>C program to check if two strings are different by one and only one character</u>

#include<stdio.h>            

#include<string.h>    

//driver function        

int main()

{

   int result;  

char f_string[100],s_string[100];  /* Declaring  f_string and s_string as strings*/

 

printf("Enter the first string : \n");   // Taking inputs from user

  scanf("%s",f_string);                  

   printf("Enter the second string : \n"); //

  scanf("%s",s_string);                      

  int l1 = strlen(f_string);      // calculating length of strings

  int l2 = strlen(s_string);      

  int difference = 0;           // For storing the count difference in strings    

  if(l1==l2)           // Checking lengths of string

  {

      for(int i=0;i<l2;i++)    

            {

                if(f_string[i] !=s_string[i])   /*checking each character of f_string with the same character index of s_string*/

          difference++;           // updating the count difference

      }        

  }

  result=difference;

  if(result==1)               // if there is only one character difference

  printf("The two strings are replaced by one character");    

  else                        

 printf("The two strings are not replaced by one character");        

}

<u>Output</u>

Enter the first string :  lake

Enter the second string :  bake

The two strings are replaced by one character

Enter the first string :  pal

Enter the second string :  pale

The two strings are not replaced by one character

Enter the first string :  bus

Enter the second string :  bit

The two strings are not replaced by one character

Enter the first string :  kite

Enter the second string :  bit

The two strings are not replaced by one character

You might be interested in
I WILL UPVOTE!!!!!!!!!!!!!!!!!!
BabaBlast [244]
All of the answers above are correct
5 0
3 years ago
What will cloud cumputing offer
seropon [69]
Cloud computing allows computers from all around the world that are not being used to be able to do extra computations. This removes many of the limitations of a single computer and lets the user calculate things much faster.
6 0
3 years ago
Mary and Billy are moving away to college and both know in their hearts that they need to end their relationship. They move away
ivanzaharov [21]

In the case of Mary and Billy, the above is called Negotiated farewell.

<h3>What is Negotiated farewell?</h3>

In the case of  Negotiated Farewell, one can say that couples are knonw to jointly create the story of the end to what we say their marriage.

Note that Negotiated Farewell is one that is made for emotionally immature or any kind of combative people. hence, In the case of Mary and Billy, the above is called Negotiated farewell.

Learn more  about relationship from

brainly.com/question/10286547

#SPJ1

4 0
1 year ago
Which mechanism transmits rotary motion to reciprocating?
weqwewe [10]
The mechanism transmits rotary motion to reciprocating is the crank and slider. <span>A crank and slider mechanism changes straight-line motion into rotation motion. Typically found in piston engines or piston pumps, this design consists of a rod that connects to a rotating driving beam and a sliding body.</span>
5 0
3 years ago
Hy <br> Anyone from kerala?
Lera25 [3.4K]

Answer:

i dont know

Explanation:

7 0
2 years ago
Read 2 more answers
Other questions:
  • One random part of Chess is whether the white side or the black side moves first? A. True B. False
    10·2 answers
  • What is ucspi-tcp pakage in qmail??
    5·1 answer
  • Jabari is writing a program which prompts a user for a value with a decimal. Which function should he use? float() int() print()
    9·2 answers
  • With ____________________, you can insert and remove a device while the computer is running.
    11·1 answer
  • Describe how communication strengthens relationship at work and, as a result, increases your productivity
    9·1 answer
  • When you are saving a file, what does word suggest by default as the name of the document?
    8·2 answers
  • How to shutdow computer
    7·1 answer
  • Which type of game requires you to read people’s expressions to anticipate their moves?
    10·1 answer
  • A sample member of the list data is a1 = ['male', True] where the second item is True if the person is on the phone.
    15·2 answers
  • Choose the output result of the below code.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!