Loops in functions

I am using inline function/functions, the program ask the user to input the number to have its double, I want to put a loop in the program, i put the loop after Cin>> but when i run the programs so nothing happened, so where to put the loop, I want to run the program for a number times until the user gives "Zero" as an input and then the program will terminates..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  using namespace std;
inline int Double(int); // Function Prototype//

int main()
{
    int target;

    cout<<"Enter the Number to have a double of it \n" <<endl;
    cin>>target;

    target= Double(target);
    cout << "Target :" << target << endl;

    target= Double(target);
    cout << "Target :" << target << endl;

    target= Double(target);
    cout << "Target :" << target << endl;
     

    return 0;
}

int Double(int target){

return target*2;
}
I copied your code and it works fine on mine, but i did have to add one thing.
an include statement, so if you dont have one that may be your problem.

my code looks like yours except with
#include <iostream>
at the top
the above program works fine me also, I used #include <iostream> i forgot to write there,, My question is that how to place a Loop in this program... use a while loop in this program, so that it ask the user again and again for input, but when the user gives zero so the loop terminates...
line 7 while(true){
line 10 if(target == 0 ) return( 1 );
line 19 }
Oh sorry, my eyes skipped over that part while reading it.
Topic archived. No new replies allowed.