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
Describe a function that would take in any RGB value and double its intensity. What do you think happens if the input is 200, 22
Paladinen [302]

Answer:

400, 440, 418

Explanation:

Lets say it takes in 3 separate inputs. It would return the int of the input * 2, so if you passed in 200, 220, and 209 as separate inputs it would return 400, 440, and 418

6 0
3 years ago
In the ______ algorithm, the disk arm starts at one end of the disk and moves toward the other end, servicing requests till the
Ahat [919]

Answer:

elevator , SCAN

Explanation:

In the elevator algorithm, the disk arm starts at one end of the disk and moves toward the other end, servicing requests till the other end of the disk. At the other end, the direction is reversed and servicing continues. SCAN

8 0
3 years ago
_______ is the command for opening a spreadsheet object in a separate spreadsheet window. A. Edit &gt; Edit Data B. Worksheet &g
marishachu [46]
I believe the correct answer would be option D. Worksheet Object > Open is the command for opening a spreadsheet object in a separate spreadsheet window. In Microsoft excel, you can simultaneously open two worksheets so you can observe them both. 
7 0
3 years ago
Read 2 more answers
The help desk received a call from a user who cannot get any print jobs to print on the locally shared printer. While questionin
iragen [17]

Answer:

Power cycle the printer

Explanation:

To power cycle a device means to turn it off and turn it back on again.This might mean switching the power to OFF and then ON again or may require physically unplugging the device and then plugging it back in again.Power cycling the device erases the RAM and allows it to boot up with fresh information.

Typically it is a good idea to wait 5 to 10 seconds before turning the device back on to make sure it has chance to fully reset.

3 0
3 years ago
Read 2 more answers
Tony Stark wants to build a 1000 meter high tower as quickly as possible. He has unlimited resources and an unlimited budget and
Irina-Kira [14]

Answer:

bruh is this for real. Dang if it is im sorry for wasting an asnwer. if not ill give you what i think

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Choose the appropriate of an image that supports the text. You should also make sure that the image is
    12·2 answers
  • What is an effective way to assess user requests for additional features and functions
    10·1 answer
  • Which relationship is possible when two tables share the same primary key? one-to-one one-to-many many-to-one many-to-many
    15·2 answers
  • 50 POINTS PLEASE HELP MEEEEEEEEE!!!!!!
    7·2 answers
  • To run a PHP application that has been deployed on your own computer, you can enter a URL in the address bar of your browser tha
    13·1 answer
  • The Michael Porter Diamond of National Advantage is a framework that explains why countries foster successful multinational corp
    11·1 answer
  • Write a method called sum with a while loop that adds up all numbers between two numbers a and b. The values for a and b can be
    11·2 answers
  • Student aid is based on either financial need or _____ need.
    12·2 answers
  • Piers wants to take a course on XML. He is a certified web designer, but he has not used XML before. How can he use XML to impro
    8·1 answer
  • Spreadsheet allow three types of cell addressing. They include ______addresses, such as $E$1, ______addresses, such as R$3, and
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!