#include <iostream>typedef struct { std::string name; double buiyingPrice; double sellingPrice; double percentage; void calculatePercentage () { percentage = buiyingPrice/ sellingPrice; }} Product;int main() { Product *array = new Product(); std::cout << "Enter information for 5 products" << std::endl; for ( int i = 0; i < 5; i++ ) { std::cout << "Enter name: "; std::cin >> array[i].name; std::cout << "Enter buiyingPrice:"; std::cin >> array[i].buiyingPrice; std::cout << "Enter sellingPrice:"; std::cin >> array[i].sellingPrice; array[i].calculatePercentage(); std::cout << "Percentage is " << array[i] << "%" << std::endl; } return 0;}
Comments