Program is not working correctly

This program i have written shows incorrect results.Pls guide me the correct way...

#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
string Item_Name;
int Item_Price;
int Item_Quantity;
int Item_Value=0;
Item_Value=Item_Price*Item_Quantity;
cout<<"Enter Item Name:";
cin>>Item_Name;
cin.ignore();
cout<<"Enter Item Price:";
cin>>Item_Price;
cin.ignore();
cout<<"Enter Item Quantity:";
cin>>Item_Quantity;
cin.ignore();
cout<<"The total value of items purchased is:"<<Item_Value<<"\n";
cin.get();
}
Last edited on
Please use [code][/code] tags when posting code

You should move Item_Value=Item_Price*Item_Quantity;
after having given a value to Item_Price and Item_Quantity, just before displaying Item_Value
Last edited on
I am a beginner, so having difficulty with these basic programs...pls elaborate your answer.

The program i need to write is :

write a program to accept Item_name, price, and quantity. Calculate value as a product of price and quantity, and display the calculated value?
thanks a ton Bazzy!
your suggestion worked :-).
Topic archived. No new replies allowed.