- Messages
- 15
- Reaction score
- 0
- Points
- 0
this refers to the following question:
You are required to design a complete system which will enable you to read in a series of prices of products purchased by a customer, to produce the total price.
The system is then required to read in the amount paid by the customer, followed by the balance to be returned to the customer.
SOl:#include <iostream>
using namespace std;
int main()
{
int nprc;
int oprc;
int tp;
int paid;
int bal;
while (nprc !=0)
{
cout << "Enter price:";
cin>>nprc;
tp=oprc+nprc;
oprc=tp;
}
cout<<"The total price is:"<<tp<< endl;
cout<<"Enter amount paid:" ;
cin>> paid;
bal=tp-paid;
cout<<"the balance is:"<<bal<<endl;
return 0;
}
In this i keep getiing error that nprc and oprc are being used without being initialised. Why? :x
You are required to design a complete system which will enable you to read in a series of prices of products purchased by a customer, to produce the total price.
The system is then required to read in the amount paid by the customer, followed by the balance to be returned to the customer.
SOl:#include <iostream>
using namespace std;
int main()
{
int nprc;
int oprc;
int tp;
int paid;
int bal;
while (nprc !=0)
{
cout << "Enter price:";
cin>>nprc;
tp=oprc+nprc;
oprc=tp;
}
cout<<"The total price is:"<<tp<< endl;
cout<<"Enter amount paid:" ;
cin>> paid;
bal=tp-paid;
cout<<"the balance is:"<<bal<<endl;
return 0;
}
In this i keep getiing error that nprc and oprc are being used without being initialised. Why? :x