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]
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.
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:...
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
C++ 1. An array of integers is said to be a palindrome if it is read...
C++ 1. An array of integers is said to be a palindrome if it is read the same from right to left and from left to right such as 1 2 3 2 1. Implement a program that: a. Prompts the user for an integer value n which represents the number of integers to be read next. b. Create a one dimensional dynamic array with size equal to n. c. Create two pointers front and rear and make them point...