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...
data <- read.table(practicedata.cvs) # Calculate the mean, max, min, median, and sum of column "K5". If...
data <- read.table(practicedata.cvs) # Calculate the mean, max, min, median, and sum of column "K5". If there is any NA, please ignore them. # Draw any figure to describe column "K5". # Print all rows with "Play" is 1, "K1" is 1, and "K5" is NA. # Print the row of the first time in which sum of K1, K2, ..., K11 larger than 45. # Print the last row you find that sum of K1, K2, ..., K11 is...
Create a C++ program that generates a random number from 1 to 100 using the rand()...
Create a C++ program that generates a random number from 1 to 100 using the rand() function. Give the user a total 5 chances to guess the number. Stop the program and indicate the user guessed the correct number and should be applauded. Also, please find out which guess was the closest to the actual number. For example, if the rand() produces 57 and the user guessed 10, 80, 52, 33 and 44 in their respective turns then print out...
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]
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:...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT