|
-
September 30th, 2010, 08:09 PM
#1
One dimesional array
I am wanting the program to ask the user to enter a number from 1-10. When the user enters the number 1, the program should update only the first price in the array. When the user enters the number 2, the program should update only the second price in the array and so on.
here is what i have so far(im am stuck at the cout statement on how to write the statement correctly to do the above instructions ^^^^)
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
cout << fixed << setprecision(2);
//declare array
double prices[10] = {10.5, 25.5, 9.75, 6.0, 35.0, 100.4, 10.65, .56, 14.75, 4.78};
//declare variable
double num = 0.0;
//get number
cout<<" Enter a number (1-10): ";
cin>>num;
return 0;
} //end of main function
any suggestions on how to code that part?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|