#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int seed_value;
cout << "Enter the seed value:" << endl;
cin >> seed_value;
srand (seed_value);
int A[10],B[10];
for(int i=0;i<10;i++) {
A[i]=rand() % 101;
B[i]=rand() % 101;
}
int classASum = 0,classBSum = 0;
double classAAverage,classBAverage;
for(int i=0;i<10;i++) {
classASum+=A[i];
classBSum+=B[i];
}
classAAverage = classASum/10.0;
classBAverage = classBSum/10.0;
cout<<"Class A average: "<<
classAAverage<<endl;
cout<<"Class B average: "<<
classBAverage<<endl;
if(classAAverage<classBAverage) {
cout<<"Class B wins"<<endl;
} else {
cout<<"Class A wins"<<endl;
}
return 0;
}
Output:
$g++ -o main *.cpp $main Enter the seed value:5 Class A average: 44 Class B average: 41.2 Class A wins
c++ help Write a program that: Creates two finite arrays of size 10 These arrays will...
In C++ Write a function that accepts two int arrays of the same size. The first array will contain numbers and the second array will be filled out inside the function. The function should find all numbers in the array that are greater or equal to the average and fill out the second array with these numbers. You need to design the function. I tried this code but the errors returned were: expression must have a constant value #include<iostream> using...
1. Write a program that reads in two arrays (a1 and a2) of numbers and creates a new array (a3) of numbers such that the new array contains all the unique numbers of a1 and a2. Assume the input array elements are unique elements. In the main function, ask the user to enter the length of each array, declare and reads in the numbers for each array, and calculate and display the output array. Example input/output #1: Enter the length...
Language C Code Write a program that takes two integer arrays (A and B) and sums them together (element wise). A third array to accept the result should be passed in as the output argument. Assume the arrays are all the same size. The argument N is the size of the arrays. Your code should provide a function with the following signature: void array Addition (int A[], int B[], int N, int output[]) { } Your code must also provide...
Must be done in C++ 2013 microsoft visual studio Write a program that creates a 4 x 5 two-dimensional array. The program should use loops to populate the array using the rand, srand and time functions with random numbers between 10 and 60. After the values have populated the array, output the values of the array to the screen in something that looks like a 4 x 5 table.
Write a program that works with two arrays of the same size that are related to each other in some way (or parallel arrays). Your two arrays must be of different data types. For example, one array can hold values that are used in a formula that produces the contents of the second array. Some examples might be: from a previous program, populations and the associated flowrates for those populations (an int array of populations and a double array...
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...
Language: C++ Course: Computer Programming for Engineers Write a program that creates two 3x4 arrays of type "int". Populate each array with random integers between 1 and 9. Also ask the user to choose whether they want to add the arrays or subtract the second array from the first array. Output all three arrays in tabular form.
I need a c++ code please. 32. Program. Write a program that creates an integer constant called SIZE and initialize to the size of the array you will be creating. Use this constant throughout your functions you will implement for the next parts and your main program. Also, in your main program create an integer array called numbers and initialize it with the following values (Please see demo program below): 68, 100, 43, 58, 76, 72, 46, 55, 92, 94,...
Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array. The program...
Class Average Create a program that dynamically creates an array whose size depends on the user's preference. Pass the array to a calculate_avg function that is responsible for computing the average GPA of the given array. Use pointer arithmetic throughout your program. calculate_avg Create a function called calculate_avg that calculates the average of a double array and returns that average. calculate_avg() will have two parameters: a double* referring to the array an int that contains the size of the given...