#include <iostream>
#include <string>
#include <sstream>
int main(int argc, char** argv) {
std::cout << "Please enter in the size of the array you would like to create:\n\n";
std::string strSizeOfArray;
std::cin >> strSizeOfArray;
std::stringstream NumberConverter(strSizeOfArray);
int iSizeOfArray = 0;
NumberConverter >> iSizeOfArray;
float* FloatArray = newfloat(iSizeOfArray);
std::cout << "An array of " << strSizeOfArray << " float variables was created. Now we will now iterate through this array 10,000 times.\n\n";
for (int o = 0; o < 10000; ++o) {
for (int i = 0; i < iSizeOfArray; ++i) {
FloatArray[i] += 1.25f;
}
}
std::cout << "We have iterated over " << strSizeOfArray << " float variables in the array 10,000 times.\n\n Now we will print the contents of the array:\n\n";
for (int i = 0; i < iSizeOfArray; ++i) {
std::cout << "The " << i << " element in the array has the value: " << FloatArray[i] << "\n";
}
std::cout << "Now we are deleting the array.";
delete[] FloatArray;
std::cout << "Exiting...";
system("pause");
}
#include <iostream>
#include <string>
#include <sstream>
int main(int argc, char** argv) {
std::cout << "Please enter in the size of the array you would like to create:\n\n";
std::string strSizeOfArray;
std::cin >> strSizeOfArray;
std::stringstream NumberConverter(strSizeOfArray);
int iSizeOfArray = 0;
NumberConverter >> iSizeOfArray;
float* FloatArray = newfloat[iSizeOfArray];
std::cout << "An array of " << strSizeOfArray << " float variables was created. Now we will now iterate through this array 10,000 times.\n\n";
for (int i = 0; i < iSizeOfArray; ++i) {
FloatArray[i] = 0.0f;
}
for (int o = 0; o < 10000; ++o) {
for (int i = 0; i < iSizeOfArray; ++i) {
FloatArray[i] += 2.93f;
}
}
std::cout << "We have iterated over " << strSizeOfArray << " float variables in the array 10,000 times.\n\n Now we will print the contents of the array:\n\n";
for (int i = 0; i < iSizeOfArray; ++i) {
std::cout << "The " << i << " element in the array has the value: " << FloatArray[i] << "\n";
}
std::cout << "Now we are deleting the array.";
delete[] FloatArray;
std::cout << "Exiting...";
system("pause");
}