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.
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++:
// 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);
}