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
never [62]
3 years ago
6

Let f be the following function: int f(char *s, char *t){char *p1, *p2;for(p1 = s, p2 = t; *p1 != ‘\0’&& *p2 != ‘\0’; p1

++, p2++){if (*p1 == *p2) break; }return p1 –s;}What is the return value of f(“abcd”, “bccd”)?

Computers and Technology
1 answer:
siniylev [52]3 years ago
7 0

Answer:

return value =2.

Here the function f() returns the length of the substring we traversed before we find the same character at the equal index of two substrings.

Take the inputs s= “abcd” and t= “bccd”.  

• Now, p1 points to s1, i.e., p1 points to the character ‘a’ of “abcd”. And similarly, p2 points to ‘b’ of “bccd”.

• Then we compare the values at p1 and p2, are not equal, so p1 and p2 both are incremented by 1.

• Now the characters ‘b’ and ‘c’ of “abcd” and “bccd” respectively are compared. They are not equal. So both p1 and p2 both are incremented by 1.

• Now, p1 points to ‘c’ of “ abcd” that is the element at index 2 of s. And p2 points to ‘c’ of “bccd” that is the element at index 2 of t. Here value at p1 and p2 becomes equal. So the break statement is executed. We stop moving forward.

• As p1 is pointing to index 2 and s is pointing to the base that is index 0, so p1-s = 2.

Explanation:

#include<stdio.h>

int f(char *s, char *t);

void main()

{

int k = f("abcd", "bccd");

printf("%d", k);

}

int f(char *s, char *t)

{

char *p1, *p2;

for(p1 = s, p2 = t; *p1 != '\0'&& *p2 != '\0'; p1++, p2++)

{

 if (*p1 ==*p2)  

  break;  

}

return (p1-s);

}

OUPUT is given as image

You might be interested in
Analyzing an algorithm with Big O notation is useful for predicting:_______.
seropon [69]

Answer:

C. The performance of the algorithm as different amounts of inputs are processed

Explanation:

Analyzing an algorithm with Big O notation is useful for predicting:

The performance of the algorithm as different amounts of inputs are processed

7 0
3 years ago
Complete the statement below with the correct term.
kvv77 [185]

Answer:

clone

Explanation:

Many manufacturers always ensure their products are accompanied by a user manual and and a driver in a CD or can be obtained from their website to guide users on how to operate the device.

If the device has neither, it means it has been refurbished or its an imitation of the original make.

Cloned devices can easily malfunction and trouble shooting them tends to be a matter of guess work. Compared to the real device, their prices are normally  cheap compared to the real devices.

7 0
3 years ago
Read 2 more answers
You are asked by your supervisor to export NPS configuaration from a server. Your supervisor contacts you and tells you it is mi
Vesna [10]

Answer:

You must import the NPS configurations, then manually cnfigure the SQL Server Logging on the target machine.

Explanation:

The SQL Server Logging settings are not in anyway exported. If the SQL Server Logging was designed on the root machine, the a manually configure of SQL Server Logging has to be done on the target machine after the NPS configurations must have been imported.

Although administrator rights is needed at least to import and export NPS settings and configurations, while that isn’t the issue in this case. NPS configurations are moved to a XML file that is non-encrypted by default. There is no wizard or tool whatsoever to export or import the configuration files.

3 0
3 years ago
Make a list of five questions about video games
salantis [7]

Answer:

Is gaming good for us?

When were video games invented?

What was the first video game?

How are video games made?

does playing video games affect your or my health?

There you go :)

6 0
3 years ago
Read 2 more answers
What are the three workplace violence prevention strategies covered in this module?
klemol [59]
Three Workplace violence prevention strategies would be:

A.) <span>Employer and employee involvement
B.) Remain Calm
C.) Call 911

Hope this helps!</span>
8 0
3 years ago
Other questions:
  • Which of the following combinations would constitute a vertical merger?
    12·1 answer
  • How do you know what memory to purchase for your computer?
    10·1 answer
  • Hey how are yall today?
    12·2 answers
  • Unused neural connections in the brain are reduced through a process of
    7·1 answer
  • Which musical instrument would have the lowest pitch ?
    12·1 answer
  • Write a function that takes an integer value and returns the number with its digits reversed. for example, given the number 7631
    10·1 answer
  • Hubs hardware advantage's and disadvantages​
    7·1 answer
  • What is binary ????????
    5·2 answers
  • Routines will depend on the ______________________ and is found in every program you write.
    11·1 answer
  • What is the purpose of a computer network needs assessment? to evaluate how to move from the current status to the desired goal
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!