aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • C Programming Fundamentals
  • What would be the output of the following program? main()...
Multiple choice

What would be the output of the following program?

main() { char *str,*str1="I Love You"; str=malloc(strlen(str1)); strcpy(str,str1); printf("%s",str); free(str); }

  1. free() fails

  2. I Love You

  3. malloc() fails

  4. strcpy() fails

Reveal answer Fill a bubble to check yourself
C Correct answer

Keep practicing — related questions

  • What will be the output for... main() { char *p1=“name”; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20)...
  • What will be the output for... main() { char *p1=“name”; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20)...
  • 2.What will print out? main() { char *p1=“name”; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20); while(...
  • What will print out? main() { char *p1=“name”; char *p2; p2=(char*)malloc(20); memset (p2, 0, 20); while(*p...
  • What would be the output of the following program? main() { char *str[] = {"Frogs","Do","Not","Die.","They"...
  • What would be the output of the following? main() { int i=strlen("Blue")+strlen("Purple")/strlen("Red")-str...
  • What will be the output of the following: void main() { char const *ptr="abc"; ptr="xyz"; printf("%s",ptr); }
  • What will be the output of the following function? # include <stdio.h> void main() { char str[10] = “Angel”...
Play the full quiz 🎤 Practise this topic out loud
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy