How do you create a really large matrix (i.e. 3500x3500) in C
without having the program crash? I can only reach up to 2500.
It must have something to do with lack of memory. Please help!
Answer / gouri shanker m.ojha
using Dynamic memory allocation,you can create large array size.
example:m=1000000,n=1000000
void enter(int m,int n)
{
int i,j;
long int c=0;
matrix=new long int*[m]; /*m is row size*/
for(i=m-1;i>=0;i--)
{
matrix[i]=new long int[n]; /*n is col size*/
for(j=0;j<n;j++)
{
matrix[i][j]=++c;
}
delete matrix[i];
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
What is wrong with the following code? int *foo() { int *s = malloc(sizeof(int)100); assert(s != NULL); return s; }
main() { unsigned int i=10; while(i-->=0) printf("%u ",i); }
create a login program that ask username and password. if you input username or password 3 times wrong, the program will terminate else the program will prompt a message "congratulations"
main() { clrscr(); } clrscr();
main() { signed int bit=512, mBit; { mBit = ~bit; bit = bit & ~bit ; printf("%d %d", bit, mBit); } } a. 0, 0 b. 0, 513 c. 512, 0 d. 0, -513
3 Answers HCL, Logical Computers,
main() { float f=5,g=10; enum{i=10,j=20,k=50}; printf("%d\n",++k); printf("%f\n",f<<2); printf("%lf\n",f%g); printf("%lf\n",fmod(f,g)); }
how to test pierrot divisor
how to return a multiple value from a function?
Sorting entire link list using selection sort and insertion sort and calculating their time complexity
1 Answers Infosys, Microsoft, NetApp,
void main() { int x,y=2,z; z=(z*=2)+(x=y=z); printf("%d",z); }
find A^B using Recursive function
Write a routine to implement the polymarker function