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
Ludmilka [50]
3 years ago
7

Write a program that contains three methods:

Computers and Technology
1 answer:
Reil [10]3 years ago
7 0

Answer:

#include <stdio.h>//defining header file

int max (int x, int y, int z) //defining a method max that hold three parameters

{

   if(x>=y && x>=z)//defining if block that checks x is greater then y and x is greater then z

   {

       return x;//return the value x

   }

   else if(y>z)//defining else if block it check y is greater then z

   {

       return y;//return the value y

   }

   else//else block

   {

       return z;//return the value z

   }

}

int min (int x, int y, int z) //defining a method max that holds three parameters

{

if(x<=y && x<=z) //defining if block that check x value is less then equal to y and less then equal to z

{

return x;//return the value of x

}

if(y<=x && y<=z) //defining if block that check y value is less then equal to x and less then equal to z

{

return y;//return the value of y

}

if(z<=x && z<=x)//defining if block that check z value is less then equal to x  

{

return z;//return the value of z

}

return x;//return the value of z  

}

int average (int x, int y, int z) //defining average method that take three parameters

{

int avg= (x+y+z)/3;//defining integer variable avg that calculate the average

return avg;//return avg value

}

int main()//defining main method

{

   int x,y,z;//defining integer variable

   printf("Enter first value: ");//print message

   scanf("%d",&x);//input value from the user end

   printf("Enter Second value: ");//print message

   scanf("%d",&y);//input value from the user end

   printf("Enter third value: ");//print message

   scanf("%d",&z);//input value from the user end

   printf("The maximum value is: %d\n", max(x,y,z));//calling the method max

   printf("The minimum value is: %d\n", min(x,y,z));//calling the method min

   printf("The average value is: %d\n", average(x,y,z));//calling the method average

   return 0;

}

Output:

Enter first value: 45

Enter Second value: 35

Enter third value: 10

The maximum value is: 45

The minimum value is: 10

The average value is: 30

Explanation:

In the above-given code, three methods "max, min, and average" is declared that holds three integer variable "x,y, and z" as a parameter and all the method work as their respective name.

  • In the max method, it uses a conditional statement to find the highest number among them.
  • In the min method, it also uses the conditional statement to find the minimum value from them.
  • In the average method, it defined an integer variable "avg" that holds the average value of the given parameter variable.
  • In the main method, three variable is defined that inputs the value from the user end and passes to the method and print its value.      
You might be interested in
The website of an international human rights organization stores a large database of information and provides search functionali
pishuonlain [190]

Answer:

False

Explanation:

This statement is false because International human rights stores large database so its search functionality is not limited to the website.

8 0
4 years ago
Do you agree that Facebook is the best social media platform to use for interpersonal communication? Why or why not?
xxTIMURxx [149]
I think it is but it isn't as well, it could bring friends together but it could also split friendships.
4 0
3 years ago
Read 2 more answers
What is the index of 7 in this list?<br> [5, 6, 10, 7, 3, 2.51]
kotykmax [81]
5 or 7 I believe Good luck!
6 0
3 years ago
Read 2 more answers
A line in the Agile Manifesto reads, "____________ and _____________ over processes and tools". Please select which option best
nikitadnepr [17]

Answer:

Option D i.e., Individuals; Interactions is the correct option.

Explanation:

Because Agile Manifesto is the development software tool that is used to reads the line for the individuals and it also interacts with the process of the user. It also used to collaborate with their customers to negotiates the contacts of the customers.

Other option is not correct because they are not related to the following statement.

5 0
3 years ago
What is UTF-8 and why was it created?
Yuki888 [10]

Answer: UTF-8 (Unicode transformation format)  is a technique that is capable of producing any character in Unicode standard.

Explanation: UTF-8 is supporting technique that helps in changing any block of bits of any language.It is used for converting any code into the unicode characters.It was created because this coding technique that supports various languages and is also replacing the ASCII code. UTF-8 code is highly compatible with the ASCII codes and has better properties than it.

5 0
3 years ago
Other questions:
  • Consider the following class definitions.
    10·1 answer
  • The case states that google intended the limited initial rollout to be a beta test of google glass, meaning that the adopters we
    8·1 answer
  • Write a class called Counter that represents a simple tally counter, which might be used to count people as they enter a room. T
    9·1 answer
  • A ___________ organizes related commands together, under a tab.
    15·1 answer
  • What coding language should i begin with if i'm looking to get into AI ?
    11·1 answer
  • The 169.254.78.9 ip address is an example of what type of ip address
    6·1 answer
  • Which of the following reflects Moore's law? Multiple Choice The doubling of computer chip performance per dollar every two year
    11·1 answer
  • A storage location in the computer's memory that can hold a piece of data is called:
    12·1 answer
  • A student who used a regression model that included indicator variables was upset when receiving only the following output on th
    10·1 answer
  • Jonah wants to type an assignment using Word. Arrange the steps he needs to follow in the correct order.?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!