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 |
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
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"
#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }
main() { char not; not=!2; printf("%d",not); }
main( ) { int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) { printf(ā%dā ,*a); a++; } p = a; for(j=0; j<5; j++) { printf(ā%d ā ,*p); p++; } }
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!
int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }
main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }
#define assert(cond) if(!(cond)) \ (fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\ __FILE__,__LINE__), abort()) void main() { int i = 10; if(i==0) assert(i < 100); else printf("This statement becomes else for if in assert macro"); }
How can u say that a given point is in a triangle? 1. with the co-ordinates of the 3 vertices specified. 2. with only the co-ordinates of the top vertex given.
main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }
main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024