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
An attacker tried to hack into the database of a reputed organization. The attacker inserted malicious code into the query of a
babunello [35]

a.) input attack is the correct answer

4 0
3 years ago
Explain how AI smartphone software in the rental car can be a threat to privacy.
Elan Coil [88]

Answer:

The real reason why AI smartphone software in the rental car is threat to privacy is that the data transmitted can actually be exposed to security breaches in the software and so if that happens, the car is no longer under the control of the user.

Hope this helps!

4 0
2 years ago
You are planning to write a guessing game program where the user will guess an integer between one and 20. Put the commented ste
Rudiy27

Answer:

1. Generate a random number

2. Ask the user for a guess.

3. Compare the user's answer to the correct number.

4. Give the user a hint as to whether their guess is too high or too

Explanation:

Leave a like and brainist if this helped

7 0
2 years ago
A(n) ________ is a specific type of computer program that manages all programs on a computer.
Oksi-84 [34.3K]
A kernel manages the whole computer including hardware. In Unix, all processes are launched from systemd/launchd.
4 0
3 years ago
Who is the first computer programmer​
enot [183]

Answer:

Ada Lovelace was the first computer programmer

8 0
2 years ago
Read 2 more answers
Other questions:
  • When does a kernel panic occur?
    12·2 answers
  • All languages from the second generation on must be translated into machine language for the computer to be able process the inp
    8·1 answer
  • Which of the following options would you use when saving a document with a new filename? *
    12·2 answers
  • A.<br> Post-It note<br> b.<br> notebook<br> c.<br> tutor<br> d.<br> spell check
    14·1 answer
  • Which of the following terms best describes the security domain that relates to how data is classified and valued?
    14·1 answer
  • The program used to create the file where you want to insert the object is called the ____.
    12·1 answer
  • What dose AUP stand for??????????
    15·2 answers
  • When a partition is formatted with a file system and assigned a drive letter it is called a volume?
    10·1 answer
  • Assume you are using the MINUS operator to combine the results from two tables with identical structure, CUSTOMER and CUSTOMER_2
    8·1 answer
  • Which information can you apply to every page of your document with the page layout options?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!