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
Select the correct answer.
Gnesinka [82]

Answer:

D.

Explanation:

I think.

4 0
2 years ago
Julie: 3: 36, 6:72, 9:108....tell me the next 3 ratios * math*
svlad2 [7]

Answer:

12:144, 15:180,

Explanation:

8 0
3 years ago
When an entrepreneur has three employees at a busy and growing software company, what is the primary responsibility of the emplo
Sloan [31]

Answer:

A: Create the product that customers

Explanation:

I did it on edgy

5 0
3 years ago
PLEASE HELPPPPPPPPPPPPPPPPPPPPPPPP LASTTTTT QUESTION FINALLLY :)))))
aleksandrvk [35]
Last of the three.
Basic membership is free (I think).
6 0
3 years ago
It is a science fiction but the answer is not science fiction.it States ;it's inventiveness,uncertainly and futuristic ideas typ
MAVERICK [17]

Answer:

The uncertainty of inventiveness and futuristic ideas usually deal with science and technology.

Inventibility is something uncertain which promotes a risk in any system in which it is inserted. With that, we can naturally associate it with the maintenance of science and technology, because both are in need of inventing new creations, which may or may not be effective for the defeat of uncertainties and the creation of certainties.

This is usually linked to futuristic ideas, which may not fit in today's society, but which impose improvements, or not, for societies in the future. Leading to the creation of more technologies and more sciences.

3 0
2 years ago
Other questions:
  • Sometimes we write similar letters to different people. For example, you might write to your parents to tell them about your cla
    9·1 answer
  • Your computer has gradually slowed down. What's the most likely reason?
    8·1 answer
  • How can you create the first row of the table as the header of the table?
    14·2 answers
  • _____ _____ deals with the definitions properties of mathematical models of computation.
    8·1 answer
  • Write a program that receives an character and displays its Unicode. Here is a sample run: Enter an character: E The Unicode for
    8·1 answer
  • Listed items that are not in any particular order should be identified with
    8·1 answer
  • If, when asked for a date of birth, the user enters a future date, this error should be caught by a ________ check.
    8·1 answer
  • Type the correct answer in the box. Spell the word correctly.
    15·2 answers
  • Which of the following items can you locate in a document using the navigation pane? Choose the answer.
    10·1 answer
  • Which of the following could be a method for an object-oriented class called Student?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!