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
Elina [12.6K]
2 years ago
14

Create a php user defined function called MinMax. The function accepts two numbers as arguments and it returns the string: "The

minimum number is x and the maximum number is y" where x and y are the minimum and the maximum numbers respectively. For example, if the numbers 20 and 4 are passed to the function MinMax, it should return the string:
Computers and Technology
1 answer:
Diano4ka-milaya [45]2 years ago
5 0

Answer:

<?php

function MinMax($x,$y) {

 if($x > $y){

     echo("The minimum is ".$y." and the maximum number is ".$x);

 }

 else{

   echo("The minimum is ".$x." and the maximum number is ".$y);    

 }

}

MinMax(20,4);

?>

Explanation:

<?php

This defines the user function with two parameters x and y

function MinMax($x,$y) {

This checks if parameter x is greater than parameter y

 if($x > $y){

If yes, it prints x as the maximum and y as the minimum

     echo("The minimum is ".$y." and the maximum number is ".$x);

 }

If otherwised

 else{

If yes, it prints y as the maximum and x as the minimum

   echo("The minimum is ".$x." and the maximum number is ".$y);    

 }

}

This calls the function

MinMax(20,4);

?>

You might be interested in
Select the examples that best demonstrate likely tasks for Revenue and Taxation workers. Check all that apply. Brenda works for
umka2103 [35]

Answer:

Brenda works for the IRS reviewing paperwork.

Jenny reviews buildings to determine how much money they are worth

Kareem advises businesses to make sure they handle their finances correctly.

Explanation:

5 0
2 years ago
Read 2 more answers
What is the system that consists of nonproprietary hardware and software based on publicly known standards that allow third part
il63 [147K]

Answer:

Open systems

Explanation:

Open systems are very different from Open Source applications or software, it should not be confused.

Open systems work with the blend of open software standards, portability, and interoperability. Computer systems that interoperate among multiple standards and vendors to ensure that computer resources (hardware and software) are not allotted to a particular vendor. Such computer systems are considered as open systems.

For instance, computer systems that run a Microsoft Windows OS can be considered as an Open system. This is because of their capability to run different versions of the Microsoft Windows OS on that particular computer system. More clearly, A computer with Windows 10 OS, can be used to install Windows 8 OS without any issue. That same computer system can run the Windows 7 OS. This makes the computer system and open system.

5 0
2 years ago
Write a program that simulates a lottery. The program should havean array of five integers named lottery, and shouldgenerate a r
Fiesta28 [93]

Answer:

Here is the C++ program that simulates lottery:

#include<iostream>  //to use input output functions

using namespace std;  //to access objects cin cout

int main(){  //start of main function

int size= 5; // size of arrays

int range = 10;  //range of random numbers from 0 to 9

int user[size];  // user array

int lottery[size];  // lottery array

for(int i=0;i<size;i++)  //iterates through the array

lottery[i]=rand()%range;  // generates random number in specified range

cout<<"Enter "<<size<<" digits: ";  //prompts user to enter 5 digits

for(int i=0;i<size;i++)  //loops through the user array

cin>>user[i];  //reads input digits from user

int match=0;  //stores number of matching digits

for(int i=0;i<size;i++)  //iterates through array to compare user and lottery arrays

if(user[i]==lottery[i])  //if digit at i-th index of user array matches to that of lottery array

match++;  //increments count of matching digits by 1

cout<<"Lottery array: ";  // display digits of lottery array

for(int i=0;i<size;i++)  //iterates through elements of lottery array

cout<<lottery[i]<<" ";  //prints elements of lottery array with a space between them

cout<<endl;  //prints a new line

cout<<"  User  array: ";  // prints digits of user array

for(int i=0;i<size;i++) //iterates through elements of user array

cout<<user[i]<<" ";  //prints elements of user array

cout<<endl;  // prints a new line

if(match==size){  //if all the digits match

cout<<"Congratulations. You are a grand prize winner! "; }//displays this message proclaiming the user as a grand prize winner

else{  // if all digits of user array do not match with lottery array digits

cout<<"Number of digits matched: "<<match<<endl; //displays the number of matched digits

cout<<"Sorry! Better luck next time!" ;    //displays this message when all digits don't match

}

}    

Explanation:

If you want to keep the size and range fixed then you can use #define before the main() function to give a constant value to size and range as:

#define size 5

#define range 10

The program uses rand() function in order to generate random numbers for lottery array in the range of 0 through 9.

Then the program declares a user array with size = 5 and prompts user to enter 5 digits to stores in user array.

Next the program matches each digit of user array to the corresponding digit of lottery array and if the two digits match then the program increments the match variable by 1 to count the matched digits. For example, lets say lottery has the following elements:

lottery: 7,4,9,1,3

Lets say user array has following elements input by user at console

user: 4,2,9,7,3

Now at first iteration the digit 7 at 0-th index of lottery array is matched to the digit 4 at 0-th index of user array. This index is specified using variable i. These means the first element of lottery array is matched with first element of user array. As these digits are not equal so they don't match and the variable i is incremented to point to the position of next digit.

Now at second iteration the digit 4 in lottery array is matched to the digit 2 of user array. As these digits are not equal so they don't match and the variable i is incremented.

at third iteration the digit 9 in lottery array is matched to the digit 9 of user array. As these digits equal so they match and the variable match is incremented to 1 in order to count the number of matches. So value of match = 1

Now at fourth iteration the digit 1 in lottery array is matched to the digit 7 of user array. As these digits are not equal so they don't match and the variable i is incremented. The value of match also remains the same i.e. 1

at fifth iteration the digit 3 in lottery array is matched to the digit 3 of user array. As these digits equal so they match and the variable match is incremented to 1 in order to count the number of matches. So value of match = 2

Next the loop ends because the value of exceeds 5 which is the size of the array.

Next if(match==size) statement has an if condition which checks if all digits match. This is checked by comparing the count of match variable to the size of the array. The value of match is 2 and value of size is 5 so this means that all the digits do not match. Hence this condition evaluates to false. So the statement in if part will not execute and program moves to the statement: cout<<"Number of digits matched: "<<match<<endl; which displays the value of match variable i.e. 2 as:

Number of digits matched: 2

followed by statement cout<<"Sorry! Better luck next time!" ;  which displays the message:

Sorry! Better luck next time!

5 0
2 years ago
given that play_list has been defined to be a list, write an expression that evaluates to a new list containing the elements at
Tamiku [17]

Answer:

new_list = play_list[0:4]

Explanation:

5 0
2 years ago
Which statement describes the primary purpose of JavaScript?
cupoosta [38]

a.The primary purpose of JavaScript is to enable features such as validation of forms before they are submitted to the server.

<u>Explanation:</u>

On web pages before submitting the day, end user has to do client validations such as whether data enter is correct data type,  so end user for  client side validation been eiher by VBSCRIPT (visual basic script language) or (JavaScript java script).  Internet explorer or Microsoft edge uses VBSCRIPT for web page validation.

For visual basic script languages end user should have enough knowledge   on visual basic programming languages. Same away for java script end user have enough knowledge on c language.

Both Scripts are used for client side validation on success of validation end user will submit web page form for next action. JavaScript is used in most of the browser including Microsoft explorer or Microsoft edge.

5 0
2 years ago
Other questions:
  • How does the occupational outlook affect the monetary benefits of a career
    11·1 answer
  • Which term is used to describe a password-protected, encrypted data file that verifies the identity of the sender of a message?
    8·1 answer
  • Which snippet of code is in XML?
    5·1 answer
  • Digital cameras always create great photographs. <br>True <br>False
    14·2 answers
  • Now now now now mowewweedeeee
    13·1 answer
  • If a student passes off an author’s work as his or her own, the student has
    6·1 answer
  • 3.6 Code Practice on Edhesive
    10·1 answer
  • You decide to test an audio clip that you have inserted into your presentation, but before you do that you make sure that the co
    6·1 answer
  • How does the dns solve the problem of translating domain names like example.com into ip addresses?
    10·1 answer
  • Firestick optimizing system storage and applications loop
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!