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 Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?

2254


Write a program to model an exploding firecracker in the xy plane using a particle system

3866


To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']

729


Hi, i have a project that the teacher want a pyramid of numbers in C# or java...when we click a button...the pyramid should be generated in a listbox/or JtextArea...and the pyramid should have the folowing form: 1 232 34543 4567654 567898765 67890109876 7890123210987 890123454321098 90123456765432109 0123456789876543210 Plz help with codes...didn't find anything on the net.

2888


How can you relate the function with the structure? Explain with an appropriate example.

3126






What is full form of PEPSI

2117


What is the difference between proc means and proc tabulate ? explain with a simple example when you have to use means or tabulate?

4048


write a simple calculator c program to perform addition, subtraction, mul and div.

3384


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

4072


What is data _null_? ,Explain with code when u need to use it in data step programming ?

3013


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

2564


Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines

3245


Cluster head selection in Wireless Sensor Network using C programming language.

3377


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

2498


how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns

3342