Question

Create a vector of 100 integers PRG from 1 to 500. Find the max and min...

Create a vector of 100 integers PRG from 1 to 500. Find the max and min and print those out. Please use c++.

Homework Answers

Answer #1

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE

#include <iostream>
#include <vector>
#include <time.h>
using namespace std;

int main(int argc, char const *argv[])
{
srand (time(NULL));
vector<int> v;
for(int i=0;i<100;i++){
int c = rand() % 500 + 1;
v.push_back(c);
}
int max = v[0];
int min = v[0];
for(int i=0;i<100;i++){
if(max<v[i])
max=v[i];
if(min>v[i])
min=v[i];
}
cout<<"Max: "<<max<<endl;
cout<<"Min: "<<min<<endl;
return 0;
}

Know the answer?
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
Similar Questions
On Python Ask the user to input a min and a max value for a range...
On Python Ask the user to input a min and a max value for a range of numbers. Then use range(min, max) to: a) Loop through the range specified by the user and find all the numbers that are divisible by 3 and print them. b) Loop through the range and find only the first multiple of 3 and print it.
3. Create vector V of integers randomly distributed on [-10 20] .display the vector. a) Use...
3. Create vector V of integers randomly distributed on [-10 20] .display the vector. a) Use for-end loop to examine each element of the vector. If element is positive double its value ; if element is negative triple its value. Display the result. b) without using for loop find number of elements in V that are greater than 1 c) without using for loop find all of elements in V that are greater or equal to -7 and are less...
In Python: Problem 4. Write a program [call it minmax.py] that accepts three integers in the...
In Python: Problem 4. Write a program [call it minmax.py] that accepts three integers in the range [0-100] as input from the user. Your program should then determine and print the smallest and largest integers in the values entered by the user using comparison operators *not* using predefined min or max Python functions. For instance: If the user input is: 36 5 99 your program should give as output: min = 5 max = 99 If the user input is:...
Find the absolute max and absolute min of f(x)= x3 -x -1 on the interval [-1,...
Find the absolute max and absolute min of f(x)= x3 -x -1 on the interval [-1, 2]
Create a vector of 50 characters PRG from A to Z. Sort the list in reverse...
Create a vector of 50 characters PRG from A to Z. Sort the list in reverse order (from Z to A). Please use c++. Please use #include.
Write a C++ program that would report all of the Min and Max. example: 1. 95...
Write a C++ program that would report all of the Min and Max. example: 1. 95 2. 95 3. 80 4. 80 lowest 80 on test(s): 3, 4 highest 95 on test(s): 1, 2 I have started it, however, this only outputs one of the Min and Max and not all of the other instances. #include<iostream> using namespace std; int main() { int grades[10] , min , max , minIndex , maxIndex ; int n , choice , rt ,...
Use the below methods to normalize the following group of data: 100, 200, 500, 700, 900...
Use the below methods to normalize the following group of data: 100, 200, 500, 700, 900 (a) normalization by decimal scaling (b) z-score normalization (c) z-score normalization using the mean absolute deviation instead of standard deviation (d) min-max normalization by setting min = 0 and max = 1
The Java program should sum the odd integers from 1 to the integer that the user...
The Java program should sum the odd integers from 1 to the integer that the user enters. For example, if the user enters 30, the program should sum the odd integers from 1 to 30.   Print "Please enter a positive nonzero integer." Declare a Scanner and obtain an integer from the user.   Use a Do...while statement and calculate the sum Use the integer that the obtained from the previous step for the loop-continuation condition. Display the sum Print the sum...
Find the absolute extrema (absolute max/min) of ?(?, ?) = ?? − ? − 2? +...
Find the absolute extrema (absolute max/min) of ?(?, ?) = ?? − ? − 2? + 8 on the triangular region ? with vertices (0,0), (4,0), ??? (0,4). Draw the region and call the boundary on the x-axis ?1 (?, ?), the boundary on the y-axis ?2 (?, ?), and the boundary on the diagonal of the triangle ?3 (?, ?). Note: Re-write each boundary as a function of one-variable.
find absolute max and min f(x)= ln(x^3 -2x^2 +x) [1/4, 3/4]
find absolute max and min f(x)= ln(x^3 -2x^2 +x) [1/4, 3/4]
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT