• We need your support!

    We are currently struggling to cover the operational costs of Xtremepapers, as a result we might have to shut this website down. Please donate if we have helped you and help make a difference in other students' lives!
    Click here to Donate Now (View Announcement)

VC++ help needed!!

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
 
Messages
2
Reaction score
0
Points
0
try initializing them out of local scope i.e initialize them before your int main().
 
Top