Calculating the prime numbers between two integers
Use better variable names. Or, alternatively, include comments to show what the variables are for.
Reformat the code with better indentation.
Do not use using namespace std. That is just bad practice.
Instead of looping j from 2 to i, you can just loop upto floor(sqrt(i) + 1).
Do not define i, j and k for such a large scope. Keep their scopes minimal.
Since your inputs would always be positive integers, use unsigned.
This is just a personal convention, and you're not bound to it. I like to define variables in the order bool, char, int, long int, float, double, ... so on.




# include &lt;iostream&gt;
# include &lt;cmath&gt;

# define ULI unsigned long int

int main () {
    bool is_prime;
    int num_cases;
    ULI cases[100][2];
    std::cin&gt;&gt;num_cases;

    for(int i = 0; i &lt; num_cases; i++)
       std::cin &gt;&gt; cases[i][0] &gt;&gt; cases[i][1];
    for(int k = 0; k &lt; num_cases; k++) {
        ULI m = cases[k][0],
            n = cases[k][1];
        for(ULI i = m; i &lt;= n; i++) {
            is_prime = true;
            ULI max = (ULI) sqrt(i) + 1;
            for(ULI j = 2; j &lt; i; j++)
                if(i % j == 0)
                    is_prime = false;
            if(is_prime)
                std::cout&lt;&lt;i&lt;&lt;std::endl;
        }
    }
    return 0;
}