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
vagabundo [1.1K]
3 years ago
13

Write a C program that stores N random numbers in an array named rA[ ] and determine the largest, smallest, and average values o

f this array. Display the array elements that store these values. The random numbers range from -50 to +50. N is a command line argument.
Computers and Technology
1 answer:
Aliun [14]3 years ago
4 0

Answer:

// program in C.

// headers

#include <stdio.h>

// headers

#include <stdlib.h>

// headers

#include <limits.h>

// main function

int main(int argc, char** argv)

{

   // read value of N from command line arguments

   int N=atoi(argv[1]);

   // variables

   int max=INT_MIN;

   // variable

   int min=INT_MAX;

int rA[N],i;

// fill the array with random number

for(i=0;i<N;i++)

{

    // generate random number from -50 to +50

    rA[i]=rand()%101-50;

    // find the Maximum

    if(rA[i]>max)

    max=rA[i];

    // find the Minimum

    if(rA[i]<min)

    min=rA[i];

}

// print values of array

printf("values of the array are:");

for(i=0;i<N;i++)

{

    printf("%d ",rA[i]);

}

// print Maximum

printf("\nMaximum value is:%d",max);

// print Minimum

printf("\nMinimum value is:%d",min);

return 0;

}

Explanation:

Read value of N from command line.Then create an array of size N.Fill the array with random number from -50 to +50.Then find the Maximum of all the elements and  assign it to variable "max" and find Minimum from all and assign it to variable "min". then print all the elements of the array, Minimum and Maximum.

Output:

command line argument=10

values of the array are:-18 -18 4 -38 2 6 -42 -20 -6 44 -6 -11 15 -31 1                                                    

Maximum value is:44                                                                                                        

Minimum value is:-42

You might be interested in
What is the difference between delete and backspace key?​
vladimir2022 [97]
They are the same thing
5 0
3 years ago
Read 2 more answers
A newspaper publishes a negative editorial on how local politicians are dragging their feet in building a new bridge. Select the
jeka57 [31]
Your answer would be
A. The editorial is data.
I just took this test :)
6 0
3 years ago
Read 2 more answers
An array name is a pointer constant because the address stored in it cannot be changed during runtime.
choli [55]
The answer to your question would be option B- False
5 0
2 years ago
Read 2 more answers
In critical thinking, an argument is:
djverab [1.8K]
C... it’s c ok.......................
6 0
3 years ago
Read 2 more answers
Which intel processor technology interconnects the processor, chipset, and wireless network adapter as a unit, improving laptop
Ira Lisetskai [31]
Apu?
....................
8 0
3 years ago
Other questions:
  • Because you do not know every possible future use for the data TerramEarth collects, you have decided to build a system that cap
    15·1 answer
  • Mobile devices need to work within limited screen space ? true or false
    9·2 answers
  • Please help me with question 1!
    8·2 answers
  • Which of the following can computer maintenance software determine?
    6·1 answer
  • A small company has hired you to take over its IT needs. The company currently has seven on-site employees and 12 remote employe
    12·1 answer
  • Write a recursive function that prints out the items of a (possibly empty) singly linked list of integers in reverse order. The
    5·1 answer
  • Each sentence in the paragraph below has a number. Choose the number of two sentences that are in the wrong order in this story.
    14·1 answer
  • the front desk of the Nocete's Hotel will comlute the total room sales (TRS) of Room 101.The room was occupied three times and t
    6·1 answer
  • How do you handle sensitive data?
    15·1 answer
  • Pam wants to make a note for other programmers in her Python code. How should the line of code for the note begin?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!