adplus-dvertising
frame-decoration

Question

What is the output of this program?
#include <stdio.h>
#include  <stdlib.h>
int main()
{
 struct test
 {
   int i;
   float f;
   char c;
 };
 struct test *ptr;
 ptr = (struct test *)malloc(sizeof(struct test));
 ptr ->f = 5.5f;
 printf("%f", ptr->f);
 return 0;
}

a.

5.5

b.

5

c.

5.5

d.

0

Posted under C Programming

Answer: (c).5.5

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?

Similar Questions

Discover Related MCQs

Q. When we dynamically allocate memory is there any way to free memory during run time?

Q. Can we increase the size of statically allocated array?

Q. Can We increase the size of dynamically allocated array?

Q. If malloc() successfully allocates memory it returns the number of bytes it has allocated.

Q. malloc() returns a NULL if it fails to allocate the requested memory.

Q. Where does the uninitialized data gets stored in memory?

Q. malloc() allocates memory from the heap and not from the stack.

Q. malloc() returns a float pointer if memory is allocated for storing float's and a double pointer if memory is allocated for storing double's.

Q. Which languages necessarily need heap allocation in the run time environment?

Q. Which of the following is/are true?

Q. Among 4 header files, which should be included to use the memory allocation functions like malloc(), calloc(), realloc() and free()?

Q. Which function is used to delete the allocated memory space?

Q. What is the return type of malloc() or calloc()?

Q. Which of the following statement is correct prototype of the malloc() function in c ?

Q. Specify the 2 library functions to dynamically allocate memory?

Q. What function should be used to free the memory allocated by calloc() ?

Q. Which header file should be included to use functions like malloc() and calloc()?

Q. In the following code what is 'P'?
typedef char *charp;
const charp P;

Q. In the following code, the P2 is Integer Pointer or Integer?
typedef int *ptr;
ptr p1, p2;

Q. Which of the following are correctly formed #define statements in C?