ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
I use turbo C which allocates 2 bytes for integers and 4 
bytes for long. I tried to declare array of size 500000 of 
long type using the following code...

long *arr;
arr=(long *)(malloc)(500000 * sizeof(long));

It gives a warning that "Conversion may lose significant 
digits in function main"...

And the resulting array size was very less around 8400 as 
compared to 500000. Any suggestions will be welcomed....

 Question Submitted By :: Anshu Ranjan
I also faced this Question!!     Rank Answer Posted By  
 
  Re: I use turbo C which allocates 2 bytes for integers and 4 bytes for long. I tried to declare array of size 500000 of long type using the following code... long *arr; arr=(long *)(malloc)(500000 * sizeof(long)); It gives a warning that "Conversion may lose significant digits in function main"... And the resulting array size was very less around 8400 as compared to 500000. Any suggestions will be welcomed....
Answer
# 1
good morning to you.....


here what i suggest is that , at the time of dynamic memory allocation the memory would not been in the position to allocate that much of huge memory at a single instance...... UR MEMORY WILL BE INCAPABLE IF U TRY TO ALLOCATE A HUGE AMOUNT LIKE ABOVE FOR UR USE.......

u try this.... you declare an array size of 200 or 300... this will give a warning that MEMORY FULL........ the one of the disadvantages in C is that we cant balance a very large amount of data's which are outside the range .... so only we will go for DATA BASE....... 



hope this helps u for getting some ideas.......

thank u
 
Is This Answer Correct ?    0 Yes 0 No
Vignesh1988i
 
  Re: I use turbo C which allocates 2 bytes for integers and 4 bytes for long. I tried to declare array of size 500000 of long type using the following code... long *arr; arr=(long *)(malloc)(500000 * sizeof(long)); It gives a warning that "Conversion may lose significant digits in function main"... And the resulting array size was very less around 8400 as compared to 500000. Any suggestions will be welcomed....
Answer
# 2
I want to make a point here...I am not sure whether there is a limit to amount of memory that you can allocate using malloc...

I used this code in a program and it ran perfectly fine...

--------------
char **a;
int **val;

a =(char **) malloc ( 1000 * sizeof *a );
 for ( i = 0; i < 1000; i++ )
  a[i] =(char *) malloc ( 1000 * sizeof *a[i] );
 val =(int **) malloc ( 1000 * sizeof *val );
 for ( i = 0; i < 1000; i++ )
  val[i] =(int *) malloc ( 1000 * sizeof *val[i] );

---------------
 
Is This Answer Correct ?    0 Yes 0 No
Anshu Ranjan
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
WAP to accept rollno,course name & marks of a student & display grade if total marks is above 200?  2
fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? } NDS13
Look at the Code: #include<string.h> void main() { char s1[]="abcd"; char s2[10]; char s3[]="efgh"; int i; clrscr(); i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd")); printf("%d",i); } What will be the output? A)No output B) A Non Integer C)0 D) Garbage Accenture5
fn f(x) { if(x<=0) return; else f(x-1)+x; } HCL3
char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable) Mascot6
Suppose I want to write a function that takes a generic pointer as an argument and I want to simulate passing it by reference. Can I give the formal parameter type void **, and do something like this? void f(void **); double *dp; f((void **)&dp);  1
main() { int a=0; if(a=0) printf("Ramco Systems\n"); printf("India\n"); } output? Ramco6
find the output of the following program main() { int x=5, *p; p=&x; printf("%d",++*p); } TCS4
find second largest element in array w/o using sorting techniques? use onle one for loop. Zycus-Infotech2
what is difference between array and structure? TCS19
Write a routine that prints out a 2-D array in spiral order! Lucent1
Write a program to compute the following 1!+2!+...n!  3
int *a[5] refers to TCS8
main is a predefined or user define function if user defined why? if predefined whay? TCS2
what is calloc and malloc?  1
what is const volatile?  1
why the execution starts from main function  9
Can we include one C program into another C program if yes how? Infosys4
How to reverse a string using a recursive function, without swapping or using an extra memory? Motorola18
What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; main() { BAD g1; g1=1; printf("%d",g1); } ADITI3
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com