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 |
how to swap 3 nos without using temporary variable
Give a oneline C expression to test whether a number is a power of 2?
25 Answers EA Electronic Arts, Google, Motorola,
#include <stdio.h> main() { char * str = "hello"; char * ptr = str; char least = 127; while (*ptr++) least = (*ptr<least ) ?*ptr :least; printf("%d",least); }
main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }
why the range of an unsigned integer is double almost than the signed integer.
void main() { int c; c=printf("Hello world"); printf("\n%d",c); }
write a c program to Reverse a given string using string function and also without string function
#include<stdio.h> int main() { int a=3,post,pre; post= a++ * a++ * a++; a=3; pre= ++a * ++a * ++a; printf("post=%d pre=%d",post,pre); return 0; }
Under linux environment can u please provide a c code for computing sum of series 1-2+3-4+5......n terms and -1+2-3+4-5...n terms..
how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.
0 Answers Mbarara University of Science and Technology,
main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }
#include <stdio.h> int main(void) { int a=4, b=2; a=b<<a+b>>2 ; printf("%d",a); return 0; }