Need program to repeat itself

I am trying to get my program to repeat itself after doing something through if statements. I have Windows 10 and am using Code::Blocks.
Thanks in advance.
I don't know what Code::Blocks is or what you are trying to do, but you should trying use a loop to repeat the code.
You should use Visual Studio 2015 Community Edition (free) if you're only using Windows.

Code::Blocks is an IDE I typically see Linux users using, but even then it's very rare I see people using it anymore.


Your description is vague, but you should familiarize yourself with the basics of programming/scripting and you'll understand how to make a block of code repeat itself.

The concept is almost identical across all programming languages. The syntax will vary but on C++:

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// examples of 3 different types of loops

// function prototype. (this tells my main() function that a function exists
//    somewhere since main() comes before the funcion
int my_function(int my_parameter);

int main()
{
  int my_integer_variable = 0;

// for loop
// I want to repeat something until some sort of condition is false
//   but also want to perform an action before each time
//   the loop repeats
  for(int i = 0; i<10; ++i)
  {//    condition^      ^ action
    // I'm going to increment my_integer_variable 10 times
    ++my_integer_variable;
  }

// while loop
//   for repeating as long as a condition remains true
  while(my_integer_variable != 15)
  {
     // going to keep adding 1 to my_integer_variable until
     //  the condition is no longer true
     //  it will not be true when my_integer_variable is equal to 15
     my_integer_variable += 1;
  }

// recursive function loop
//  this function will execute and then call itself again
//   with the result of its execution.
//  it continue to call itself until the parameter is
//   greater than or equal to 1000, then returns 1000;
  my_function(my_integer_variable);

}

int my_function(int my_parameter)
{
  if(my_parameter >= 1000)
     return 1000;
  my_parameter += 100;
  return my_function(my_parameter);
}
Topic archived. No new replies allowed.