Hola, so recently I started my programming course and I am not good at it yet.
So let's get into the main problem, I have to make a program: "user inserts two numbers "m" & "n" (int m, n;)and program has to find all the prime numbers between "m" & "n"
So I am not sure how to do it, should I use some kind of an array or what, any help would be appriciated!
Well, assuming you know how to check for a prime number then a loop would be good here, create a loop from m to n and inside that loop check if the current loop position is a prime number and if it is then display it.
#include <iostream>
int main()
{
// these are just dummy variables, in
// your code you would be asking the
// user what numbers.
int m = 10;
int n = 20;
// for (initialization; condition; increase) statement;
// so here I initialise number to m, the condition tells
// it to loop while number is below or equal to n, and
// lastly we say number++ to increase each time we loop
for (int number = m; number <= n; number++)
{
// we loop and each time we do, the
// number variable will increase by
// 1
// lets test this by displaying it.
std::cout << number << std::endl;
}
return 0;
}