Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS A C++ ASSIGNMENT #include #include using namespace std; using namespace std::chrono; int main() { cout < < How many items should be summed?

THIS IS A C++ ASSIGNMENT

#include

#include

using namespace std;

using namespace std::chrono;

int main() {

cout << "How many items should be summed? ";

int items;

cin >> items;

int* data;

//TODO: Create your dynamic array, it should be items big

//TODO: Fill your dynamic array with the values 1 through items

//used for timing

high_resolution_clock::time_point t1 = high_resolution_clock::now();

//this variable will accumulate your sum

long long int sum = 0;

//TODO: create a for loop that loops over your array, summing all data in the array

//Grab the time again now that youre done

high_resolution_clock::time_point t2 = high_resolution_clock::now();

long long int duration = duration_cast(t2 -t1).count();

cout << "sum: " << sum << endl;

cout << "duration: " << duration << endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

Students also viewed these Databases questions