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
What is the biggest difference between single system recording and double system recording?
Alinara [238K]

The most significant difference between single and double system recording is where the audio sound is recorded from. In a double system recording, the images and the sound are recorded in two different devices. Sound is recorded on the first device, and the picture and the reference audio is recorded on the second device. On the other hand, in a single system, the audio is captured silmutaneously with the image on the same device. The double recording system is used more so if you do not have a camera that has an advanced audio quality input. If you have a dedicated audio device that can capture audio on an independent device, then you will be guaranteed to get a robust sound quality.

7 0
3 years ago
Read each of the following statements about Computer Science and explain why you think that statement is true.
larisa86 [58]

Answer:

sytaragadr

Explanation:

3 0
3 years ago
If a menu item requires additional information from the user, the Windows standard is to place a(n) ____ at the end of the capti
elena-s [515]

Answer:

elipses

Explanation:

According to my research on information technology, I can say that based on the information provided within the question the windows standard in this situation would be to place an ellipses at the end of the caption. This is because in the English language an ellipses (...)  usually indicates an intentional omission of a word or sentence, which in computer science is used to give the user an indication that it requires further user input.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

4 0
4 years ago
IF ANSWER I WILL BE REALLY HAPPY
butalik [34]

Answer:

C.

Explanation:

7 0
3 years ago
Read 2 more answers
The four functions of a computer are
ehidna [41]
The four basic functions of a computer are input, processing, output and storage.
6 0
3 years ago
Other questions:
  • Tags that provide browsers with information about document characteristics
    15·1 answer
  • The ___________ command waits for windows 7 to save your work and then turns off the computer fans and hard disk. answer shut do
    11·1 answer
  • What are two most common types of microcomputers? a. IBM-style PCs and Macs c. Clients and Servers b. Mainframes and Minicompute
    14·1 answer
  • Which of the following is a variable expense for many adults?
    11·2 answers
  • . The NFiPA 704 system uses a numerical value between _____ and _____ to indicate the level of hazard for that particular chemic
    7·1 answer
  • Given two integer variables distance and speed, write an expression that divides distance by speed using floating point arithmet
    13·1 answer
  • I am needing help with this homework of mine.
    7·1 answer
  • Part 1: Plan and Write the Pseudocode
    7·1 answer
  • What is the biggest problem with technology today?
    10·1 answer
  • Choose all items that represent essential features of excellent navigation menu design.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!