[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

C Programming :: Dynamic Memory Allocation - Discussion

Home > C Programming > Dynamic Memory Allocation > MCQs Questions Discussion

4 / 18

What is the output of the following 'C' program ?

#define MAX 50 
int fun1()
{
char *s1;
s1=(char *) malloc (MAX*sizeof(char));
s1="hello";
printf("%d",s1);
free(s1);
}
int fun2() 
{
char *s;
s=(char *) malloc (MAX*sizeof(char));
strcpy(s,"hello");
printf("%d",s);
free(s);
}
int main ()
{
fun1();
fun2();
return 0;
}

ACompilation Error

Bhello hello

CSegmentation fault

Dhello Segmentation fault

Answer: Option (Login/Signup)

Show Explanation

Asked In :: Societe Generale

Post Your Answer Here:     

No Discussion on this question yet!