void main()

{

int *mptr, *cptr;

mptr = (int*)malloc(sizeof(int));

printf(“%d”,*mptr);

int *cptr = (int*)calloc(sizeof(int),1);

printf(“%d”,*cptr);

}



void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); ..

Answer / susie

Answer :

garbage-value 0

Explanation:

The memory space allocated by malloc is uninitialized,
whereas calloc returns the allocated memory space
initialized to zeros.

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Code Interview Questions

Write a routine that prints out a 2-D array in spiral order

3 Answers   Microsoft,


How we print the table of 3 using for loop in c programing?

7 Answers  


#define prod(a,b) a*b main() { int x=3,y=4; printf("%d",prod(x+2,y-1)); }

1 Answers  


code of a program in c language that ask a number and print its decremented and incremented number.. sample output: input number : 3 321123

1 Answers   HCL,


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

0 Answers  






main() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?

2 Answers  


main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }

7 Answers  


main() { static int a[3][3]={1,2,3,4,5,6,7,8,9}; int i,j; static *p[]={a,a+1,a+2}; for(i=0;i<3;i++) { for(j=0;j<3;j++) printf("%d\t%d\t%d\t%d\n",*(*(p+i)+j), *(*(j+p)+i),*(*(i+p)+j),*(*(p+j)+i)); } }

1 Answers  


3) Int Matrix of certain size was given, We had few valu= es in it like this. =97=97=97=97=97=97=97=97=97=97=97 1 = | 4 | | 5 | &= nbsp; | 45 =97=97=97=97=97=97=97=97=97=97=97 &n= bsp; | 3 | 3 | 5 | = | 4 =97=97=97=97=97=97=97=97=97=97=97 34 |&nbs= p; 3 | 3 | | 12 | &= nbsp; =97=97=97=97=97=97=97=97=97=97=97 3 | &nbs= p; | 3 | 4 | = | 3 =97=97=97=97=97=97=97=97=97=97=97 3 | = ; | | | = ; 3 | =97=97=97=97=97=97=97=97=97=97=97 &= nbsp; | | 4 | = ; | 4 | 3 We w= ere supposed to move back all the spaces in it at the end. Note: = If implemented this prog using recursion, would get higher preference.

0 Answers   RoboSoft,


main() { while (strcmp(“some”,”some\0”)) printf(“Strings are not equal\n”); }

1 Answers  


#define a 10 void foo() { #undef a #define a 50 } int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } explain the answer

1 Answers  


C statement to copy a string without using loop and library function..

2 Answers   Persistent, TCS,


Categories