Question

Dev C Question Write a coding that stores 10 random numbers below 100 in an array,...

Dev C Question

Write a coding that stores 10 random numbers below 100 in an array, stores the largest and smallest numbers in the array in max, min, and finally gets the sum of the 10 numbers. Use the following sentences.


srand (time (NULL);

int a [10];

for(i=0 ; i<10 ; i++)
{a[i] =land()%10+1; }

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The answer to this question is as follows:

The code is as follows:

#include <stdio.h>
#include <stdlib.h>
#include<time.h>

int main() {
int array[10],min,max;
srand (time (NULL));
for (int i = 0; i < 10; i++) {
array[i]= rand() % 100 + 1;
printf("%d ",array[i]);
}
max=array[0];
min=array[0];
for(int i=0;i<10;i++)
{
if(max<array[i])
{
max=array[i];
}
if(min>array[i])
{
min=array[i];
}
}
printf("\nMinimum is %d",min);
printf("\nMaximum is %d",max);

return 0;
}

The input and output are provided in the screenshot below:

1 2. 3 4 5 6 #include <stdio.h> #include <stdlib.h> #include<time.h> 7 int main() { int array(10), min, max; srand (time(NULL

Add a comment
Know the answer?
Add Answer to:
Dev C Question Write a coding that stores 10 random numbers below 100 in an array,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a program that creates an array of 500 random numbers between -10 and 10. Write...

    Create a program that creates an array of 500 random numbers between -10 and 10. Write several functions: Function 1 - prints the array with a certain number of elements per line. Prototype: void printArray(int array[], int numElements, int numPerLine, ostream &os) Function 2 prints only the array elements that are evenly divisible by an input number. Prototype: void printDivBy(int array[], int numElements, int numPerLine, int divBy, ostream &os) Function 3 takes the input array and returns the maximum, the...

  • Create a new file (in Dev C++) Modify program above to use a vector instead of...

    Create a new file (in Dev C++) Modify program above to use a vector instead of an array. Header comments must be present Prototypes must be present if functions are used Hello and goodbye messages must be shown Vector(s) must be used for implementation Use comments and good style practices ====================================================================================================== #include <iostream> using namespace std; int main() { cout<<"Welcome! This program will find the minimum and maximum numbers in an array."<<endl; cout<<"You will be asked to enter a number...

  • Write a program in C that creates an array of 100 random numbers from 0-99. The...

    Write a program in C that creates an array of 100 random numbers from 0-99. The program sums the random numbers and prints the sum.  It then writes the numbers to a new file using open, close and write. Then looks in the current directory for files that match the pattern “numbers.XXXX”. For each file, open the file and read the file. You can assume that the file will contain 100 integers. Sum the integers. Print the filename and the sum...

  • In the "Go" button add 15 random numbers in the array using a random number generator....

    In the "Go" button add 15 random numbers in the array using a random number generator. Remove the call to "SetToZero" and the code following. Remove the "SetToZero" method. Add Access Keys of your choice Assign an accept button Assign cancel button (Exit) Add a Button "Find Max" Write an appropriately named method that Accepts the array Finds the largest int and returns the value "Find Max" button click Calls above method Opens a MessageBox to display the returned value...

  • Write a program that initializes an array with ten random integers and then prints out the...

    Write a program that initializes an array with ten random integers and then prints out the following: Every element at an even index; Every even element All elements in reverse order; Only the first and last elements; The minimum and maximum element The sum of all elements The alternating sum of all elements, where the alternating sum contains all elements at even index added, and the elements at odd index subtracted. Please write comments above the piece of code that...

  • Java question Q1) Use the following code snippet which generates a random sized array with random...

    Java question Q1) Use the following code snippet which generates a random sized array with random contents to complete the following problems: public int [] createRandomArray() {         int size = (int) (Math.random() * 10) + 1;         int[] array = new int [size];         for (int i = 0; i < array.length; i++) {             array[i] = (int) (Math.random() * 10 ) + 1;         }         return array;     } Assignment...

  • How do i do a random generated numbers for an array that genrates nothing but char...

    How do i do a random generated numbers for an array that genrates nothing but char by using ascii from 33 - 126 example of a function i have to make the array full of char. This way does not work and need help. void displayArray(char arr[], int size) { srand(time(NULL)); for(int i = 0; i < size; i++) { arr[i] = ( (rand() % 33) + 'a'); cout << arr[i] << " "; } }

  • Remove srand(time(NULL)); from this C++ code so that it still finds random numbers correctly. Then, Write...

    Remove srand(time(NULL)); from this C++ code so that it still finds random numbers correctly. Then, Write a program that adds the following to the fixed code. • Add a function that will use the BubbleSort method to put the numbers in ascending order. – Send the function the array. – Send the function the size of the array. – The sorted array will be sent back through the parameter list, so the data type of the function will be void....

  • REWRITE the code below and declare a class that holds an array of 10. Create a...

    REWRITE the code below and declare a class that holds an array of 10. Create a constructor that initializes the array with random integers 1 and 100. Write a member function to show the entire array and another to sort the array. Rewrite with instruction above: //Exchange Sort Function for Descending Order void ExchangeSort(vector<int> &num) {      int i, j;      int temp;   // holding variable      int numLength = num.size();      for (i=0; i< (numLength -1); i++)       {...

  • a. Write a function named findmax() that finds and displays the maximum values in a two...

    a. Write a function named findmax() that finds and displays the maximum values in a two dimensional array of integers. The array should be declared as a 10 row by 20 column array of integers in main() and populated with random numbers between 0 and 100. b. Modify the function written above so that it also displays the row and column numbers of the element with the maximum value. I have this so far, and but it's only finding the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT