C++ please
Write a program that allows a user to enter any number of product prices and show the total of all of the products. Use 0.00 as a sentinel value. (while loop)
Program:
#include <iostream>
using namespace std;
void totalPrice(); // function prototype
int main() {
totalPrice(); // calling function
return 0;
}
void totalPrice() // Called function
{
float total=0,price; // variable declaration
cout<<"Enter product price: ";
cin>>price; // Accept price
while(price!=0) // If the price is 0 or not
{
total = total + price; // Caclculate the total
cout<<"Enter product price: ";
cin>>price; // Accept the price
}
cout<<"Total price of the products is "<<total<<endl; // print the total product price
}
Output:
Get Answers For Free
Most questions answered within 1 hours.