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
mamaluj [8]
4 years ago
7

1. Declare two dimensional double array with 3 rows and 4 columns. a) Use scanf to read the elements for this array. b) Write a

function that computes the average of the above array. c) Write a function that computes the minimum of the above array.
Computers and Technology
1 answer:
Kobotan [32]4 years ago
8 0

Answer:

Following are the program in the C Programming Language:

#include <stdio.h> //header file

float avgs(int a[3][4]){ //define function

 int s =0, c=0; //set integer type variable

 float avg=0;   //set float type variable

 //set for loops to find sum of an array

 for (int i = 0; i < 3; i++){

   for (int j = 0; j < 4; j++){

   s = s + a[i][j];

   c +=1;

   }

 }

 //find average of an array  

 avg = s / c;

 return avg;

}

int min(int a[3][4]){//define function

 int m = a[0][0];  //set integer type variable  

 //set for loop for traversing

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

 {  for (int j = 0; j < 4; j++){

     if(m > a[i][j])

       m = a[i][j];

   }

 }

 return m;

}

int main(){//define main function

 int a[3][4];//set integer type Array

 printf("Enter the elements of an array:\n");

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

  for (int j = 0; j < 4; j++)

     scanf("%d", &a[i][j]);

 printf("\n Average of an array: %f", avgs(a));

 printf("\n Smallest element of an array: %d", min(a));

 return 0;

}

Explanation:

Here, we define header file "stdio.h" for print or scan the data.

Then, we define float type function "avgs()" for find the average of an array inside it.

  • we set two integer type variable for sum and count
  • we set float type variable to store average of an array
  • we set the for loops for the sum of an array.
  • we divide sum from count to find average and return it.

Then, we define integer type function "min()" to find the minimum value of an array.

  • we set integer type variable to store array elements
  • we set the for loops for traversing the array
  • we set if statement to find minimum value of an array.
  • we return the minimum value of an array.

Then, we define integer type "main()" function to call both the functions.

  • we set integer type array variable and get input from the user in it with the help of for loops.
  • we call both the functions with message and return 0.

You might be interested in
For safety, the lights on your vehicle must be in good working condition. Which statement about
bija089 [108]
I think the answer is a but I am not for sure
7 0
3 years ago
Read 2 more answers
Three primary types of data that a forensic investigator must collect, in this order: 1.Volatile data 2.Temporary data 3.Persist
posledela

Answer:

1. volatile data

2. temporary data

3. persistent data

seems like you already got it correct

Explanation:

7 0
2 years ago
Write a static method named anglePairs that accepts three angles (integers), measured in degrees, as parameters and returns whet
padilas [110]

Answer:

The java program for the scenario is given below.  

import java.util.*;

public class Test

{

// method returning sum of all digits in the integer parameter

static boolean anglePairs(int a1, int a2, int a3)

{

   // variable to hold sum of two complementary angles

   int comp=90;  

   // variable to hold sum of two supplementary angles

   int supp=180;

   // boolean variable to hold result

   boolean result = false;

   if( (a1+a2 == comp) || (a2+a3 == comp) || (a1+a3 == comp) )

   {

       if( (a1+a2 == supp) || (a2+a3 == supp) || (a1+a3 == supp) )

           result = true;

       else

           result = false;

   }    

           // return variable result

       return result;

}

public static void main(String[] args)

{

   // method is called by passing three positive angles

   System.out.println("The pair of angles have both complementary and supplementary angles " + anglePairs(100, 80, 90) );    

}

}

OUTPUT

The pair of angles have both complementary and supplementary angles false

Explanation:

The program works as described below.

1. The method, anglePairs(), is declared as static having return type as Boolean which takes three positive integer parameters.

static boolean anglePairs(int a1, int a2, int a3)

{

}

2. The integer variable, comp, is declared and initialized to 90.

3. The integer variable, supp, is declared and initialized to 180.

4. The Boolean variable, result, is declared and initialized to false.

5. Using if-else statements, sum of two angles are compared with the variables, comp and supp.

6. If the sum of any two angles match with both, comp and supp, variables, the Boolean variable, result is assigned value true. Otherwise, result is assigned value false.

7. The value of result is returned.

8. Inside main() method, the function anglePairs() is called and three positive numerical values are passed as parameters.  The output is displayed.

9. All the above code is written inside the class Test.

10. User input is not taken since it is not mentioned in the question.

8 0
3 years ago
Review the HTML tags that we have gone over in this lesson. Research HTML tags on the web and identify two new tags. Use these t
NemiM [27]

Answer:

w3schools

Explanation:

there is a webiste called w3schools that really helped me through my web page design class, just click on learn html

4 0
3 years ago
Which payment method typically charge is the highest interest rates?
jek_recluse [69]

The highest amount is Credit. The more you wait the higher the interest, higher the interest the more you pay, and no one wants to play more. Stay safe use debit as much as you can

8 0
3 years ago
Other questions:
  • The brainly home page uses about 112% of my cpu. (On chromebook) any ideas to help increase performance?
    7·2 answers
  • Whats the wire that connects to the wifi box
    15·2 answers
  • You’re driving down the highway when one of your tires suddenly blows out.<br> you should
    10·2 answers
  • Semantic search engines use NLP, contextual cues, synonyms, word variations, concept matching, specialized queries, and other st
    6·1 answer
  • A barcode is a Select one: a. coded instruction needed to control computer hardware. b. confidential computer code required by H
    7·1 answer
  • Dennis would like to include a video in a presentation. The source of the video is on the internet, but he would like to ensure
    10·2 answers
  • You are looking at computer ads. One has a processor that is 3.64GHz. What does this mean?
    5·1 answer
  • Jason is the motion picture projectionist at the local IMAX theater. This means that he runs the huge movie projector so that cu
    12·1 answer
  • What is an example of work performed by an integration platform as a service (ipaas)?
    14·2 answers
  • How do I find unwanted programs on my computer?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!