I am trying to write a C++ program that reads the number of rows and columns of a 2d array and initializes row by row the array with the first prime numbers in increasing order. Using indexes.
This is what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
usingnamespace std;
int main ()
{
int rows,columns;
cout<<"Enter number of rows"<<endl;
cin>>rows;
cout<<"Enter the number of columns"<<endl;
cin>>columns;
double **A=newdouble *[rows];
int primenums, n ;
for (int i=2;i<=rows;++i )
primenums[i] = 1;
for (int i=2; i<=n/2; ++i )
for ( int j=2; i*j<=rows; ++j )
primenums[i*j] = 0;
Any guidance is appreciated. I know i am way off on the code but advice on how to go about it would be very helpful.
#include <iostream>
usingnamespace std;
int main ()
{
int rows;
int columns;
cout<<"enter no. of rows"<<endl;
cin>>rows;
cout<<"enter no. of columns"<<endl;
cin>>columns;
int **A=newint *[rows][columns];
for(int i = 0; i< rows; i++)
{
A[i] = newint[rows];
}
for (int i = 0; i < rows; i++)
for(int j =0; j<columns; j++)
}
return 0;