It will compile, and run for a split second- but then it quits itself.
I've had three people look at it, but no one can see the problem.

#include<iostream>
#include<conio.h>
#include<iomanip>
using namespace std;

void getRaise(double pay[], int size)
{
     for(int x=0; x <size, ++x;)
     pay[x] *=1.05;
     }
int main ()
{
const int SIZE=5;
double wage[SIZE] = {14.95, 17.75, 19.59, 12.9, 7.2};
cout<<"The values stored are "<<endl;
for(int x=0; x<SIZE;++x)
        cout<<fixed<<setprecision(2)<<"$"<<wage[x]<<endl;
getRaise(wage, SIZE);
cout<<"The values with a 5% raise are "<<endl;
for(int x=0; x<SIZE;++x)
        cout<<"$"<<wage[x]<<endl;
getch();
}

Thanks in advance. :)

Your for-loop is wrong ..

void getRaise(double pay[], int size)
{
// should rather be ..
for(int x=0; x <size; ++x)
...
commented: Nice catch +20
commented: It was obvious to me! +11

at the end of int main i usually put:


system("pause");
return 0;

it means you have to press a key before the console closes

Your for-loop is wrong ..

void getRaise(double pay[], int size)
{
// should rather be ..
for(int x=0; x <size; ++x)
...

To restate, since it took me a while to figure out exactly what you meant, take out the semi-colon at the end of your loop definition.

mitrmkar, please be a little more explicit next time. Noticing one minor character change can be difficult to spot without pointing out the change.

at the end of int main i usually put:

system("pause");
return 0;

it means you have to press a key before the console closes

Bad suggestion. Why call the operating system to pause a program when a simple cin waits? And pause doesn't exist on all operating systems.

The OP used getch() for that very purpose anyway, also not recommended. Why include a C header and a non-standard function for this simple task? Again, cin does it. :icon_wink:

To restate, since it took me a while to figure out exactly what you meant, take out the semi-colon at the end of your loop definition.

Note that there is also an unfortunate comma inside the original loop.

mitrmkar, please be a little more explicit next time. Noticing one minor character change can be difficult to spot without pointing out the change.

The OP is welcome to ask more questions, if needed (i.e. there was something left to be figured out). Though you may be right that in this case it might have been better to point things clearly out (only the OP knows).

Your for-loop is wrong ..

Thanks again!

mitrmkar, please be a little more explicit next time. Noticing one minor character change can be difficult to spot without pointing out the change.

When I did not have my code right in front of me, your post was helpful.
Otherwise, mitrmkar's post was enough, as copypasta helped me see the difference.

Bad suggestion. Why call the operating system to pause a program when a simple cin waits? And pause doesn't exist on all operating systems.

The OP used getch() for that very purpose anyway, also not recommended. Why include a C header and a non-standard function for this simple task? Again, cin does it. :icon_wink:

I tried to replace my getch with cin, but I don't understand what you mean.
How do I use cin in this way?

Replace getch() with cin.get()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.