I tried the Prime Generator program and it is exceeding the time limit. I do not know the concept of pointers and always try to make a program which doesn't include the use of pointers. Please suggest me a method to reduce the execution time. I know I have used too many loops but I am unsure of another way. Here is the code:
#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
int prime[t][2];
int no;
for(int i=0; i<t; i++)
{
for(int j=0; j<2; j++)
{
cin>>prime[i][j];
}
}
for(int s=0; s<t; s++)
{
while(prime[s][0]<=prime[s][1])
{
no=0;
for(int i=2; (i*i)<=prime[s][0]; i++)
{
if(prime[s][0]%i==0)
{
no=no+1;
}
}
if(no==0)
{
if(prime[s][0]!=1)
{
cout<<prime[s][0]<<endl;
}
}
prime[s][0] = prime[s][0] + 1;
}
cout<<endl;
}
cin.get();
}
Thank you so much for your help!