float cost ()
//to calculate the ammo needed
apple = choice * 16;
orange = choice * 40;
pear = choice *6;
cout << endl;
cout << "You will need\n" << apple << " to buy apple.\n" << endl;
cout << "You will need\n" << orange << " to buy orange.\n" << endl;
cout << "You will need\n" << pear << " to buy pear.\n" << endl;
//title for the user.
//also telling the user how to end the program.
cout << "\n\tThis is a program that calculate numbers" << endl;
cout << "\n\tEnter 0 to exit." << endl;
cout << "\nEnter a number? : ";
cin >> choice;
if (choice != 0)
cout << "You are ending this session." << endl;
i have change the code and remove all global variables. and when i run the code, i this what i get
1 2 3 4 5
D:\programming\C++\test1\main.cpp: In function 'float cost()':
D:\programming\C++\test1\main.cpp:12: error: 'choice' was not declared in this scope
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
in this case where should i place "choice"?