whats wrong with these code??

read 2 numbers (ex: 4 7) increment 2 and decrement 1 so it will be like these:
4 6 5 7 6 8 7. (4 plus 2 = 6 -1 = 5...)
im stuck at this point, i end up getting 14 numbers(the double) instead of seven because of the two cout´s in the loop, so i wanted to know a possible continuation for this problem.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

using namespace std;

int main()
{
    int inic,sec;
    cin>>inic;
    cin>>sec;
    for(int i=1;i<=sec;i++){

        inic=inic+2;
        inic --;
        cout<<inic<<" ";
    }

    return 0;
}

thankyou
Last edited on
Why do you think something is wrong with it?

If you have a problem, TELL US WHAT IT IS.
Hello oterus,

PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code.

It makes it easier to read your code and also easier to respond to your post.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

I found the second link to be the most help.

There are some problems in the program and a few things that can be done different, but yo need to say what the program is not doing first.

Andy
Topic archived. No new replies allowed.