Untitled
unknown
plain_text
2 years ago
837 B
12
Indexable
#include <iostream>
#include <vector>
#include <string>
// Define a structure to hold stock data
struct StockData {
std::string date;
double closingPrice;
double highPrice;
double lowPrice;
int volumeTraded;
};
int main() {
// Create a vector to hold stock data
std::vector<StockData> appleStockData;
// Add data for a specific day
appleStockData.push_back({"1/3/2024", 150.00, 155.00, 149.00, 5000000});
// Access and print the data
for (const auto& data : appleStockData) {
std::cout << "Date: " << data.date
<< ", Closing Price: " << data.closingPrice
<< ", High Price: " << data.highPrice
<< ", Low Price: " << data.lowPrice
<< ", Volume Traded: " << data.volumeTraded << std::endl;
}
return 0;
}Editor is loading...
Leave a Comment