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
Lorico [155]
3 years ago
15

Given the char * variables name1, name2, and name3, write a fragment of code that assigns the largest value to the variable max

(assume all three have already been declared and have been assigned values).
Computers and Technology
1 answer:
Assoli18 [71]3 years ago
4 0

Answer:

The following code as follows:

Code:

max=name1;   //define variable max that holds name1 variable value.

if (strcmp(name2, max)>0)  //if block.

{

   max=name2;  //assign value to max.

}

if (strcmp(name3,max)>0)   //if block.

{

  max=name3; //assign value to max.

}

Explanation:

In the above code, we define a variable that is max. The data type of max variable is the same as variables "name1, name2, and name3" that is "char". In the max variable, we assign the value of the name1 variable and use if block statement two times. In if block, we use strcmp() function that can be defined as:

  • In first if block we pass two variables in strcmp() function that is "name2 and max" that compare string value. If the name2 variable is greater then max variable value so, the max variable value is change by name2 variable that is "max=name2".
  • In second if block we pass two variables in strcmp() function that is "name3 and max" that compare string value. If the name3 variable is greater then max variable value so, the max variable value is change by name3 variable that is "max=name3".

You might be interested in
How do you validate the type of text that a user enters?
enot [183]
D, is the correct choice here. 
3 0
3 years ago
ZipCar uses cutting edge wireless technology combined with sophisticated data management and security techniques to assure that
Bingel [31]

Answer:

dependable

Explanation:

3 0
1 year ago
In general, use no more than _____ font types in a worksheet.
jek_recluse [69]
The answer is a.two
In general, use no more than two font types in a worksheet.
4 0
3 years ago
In a program, you need to store the identification numbers of 10 employees (as integers) and their weekly gross pay (as double v
dedylja [7]

Answer:

The code to the given question can be given as:

Code:

1)

2 arrays that used to store 10 employee identification number and grosspay amount in parallel and its data-type is int and double.

int Employee_id[10]; //array that store integer value

double Weekly_Gross_Pay[10]; //array that store double value

2)

Define loop for print the details of employees’ identification number and weekly gross pay.

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

{  

cout <<Employee_id[i] <<" " << Weekly_Gross_Pay[i] << endl;  

}

Explanation:

The explanation of the above code can be given as:  

In Code (1) we declare two array that's data-type is integer and double. In Employee_id array it store the integer values and Weekly_Gross_Pay it store the double value.

In Code(2) It is used to print the value of array. In that code, we used for a loop because of its entry control loop and we know the size of the array. In this loop, we declare a variable (i) and initialized the value 0 and check the condition(i)less than 1 and increment of i. It prints all the 10 values.  

5 0
3 years ago
This function returns the length of a string:
Anna71 [15]

Answer:

The strlen() function calculates the length of a given string.The strlen() function is defined in string.h header file.

Explanation:

It doesn’t count null character ‘0’. Syntax: int strlen(const char *str); Parameter: str: It represents the string variable whose length we have to find. Return: This function returns the length of string passed.

4 0
1 year ago
Other questions:
  • A financially stable person is able to
    12·2 answers
  • Because many mobile devices and personal computers today are continually connected to the Internet, securing those devices again
    6·1 answer
  • A parent is browsing through a shopping website, looking for blue-colored striped socks for her child. She is fine if the socks
    15·1 answer
  • Shape is very prominent in the image of the telephone other elements are ( Color, Space, or Line) and (Form, Space, or Texture)
    15·2 answers
  • Gear systems with __________ can have both drive and driven gears on the same shaft. a. an odd number of gears b. an even number
    6·1 answer
  • Which of the following allows the transmission of voice and often video communication over the internet?
    12·1 answer
  • What colorful format should you use to bring attention to an important sentence or phrase
    14·1 answer
  • What does this function do in the code?
    5·2 answers
  • Describe the main roles of the communication layer, the network-wide state-management layer, and the network-control application
    15·1 answer
  • How many cubic millimeters are present in 0.0923 m3?​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!