Knowee
Questions
Features
Study Tools

What will be the output of the following program? Write the answer in digits not alphabets.#include<stdio.h> int main() {     float i=10, *j;     void *k;     k=&i;     j=k;     printf("%.2f", *j);     return 0; }

Question

What will be the output of the following program? Write the answer in digits not alphabets.#include<stdio.h> int main() {     float i=10, *j;     void *k;     k=&i;     j=k;     printf("%.2f", *j);     return 0; }

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the program will be 10.00.

Here's the step by step explanation:

  1. A float variable i is declared and initialized with the value 10.
  2. A float pointer j and a void pointer k are declared.
  3. The address of i is assigned to the void pointer k.
  4. The void pointer k is assigned to the float pointer j. This is possible because a void pointer can hold the address of any data type.
  5. The value at the address held by j is printed, which is the value of i, i.e., 10.00. The "%.2f" in the printf statement is used to print the float value up to 2 decimal places.

This problem has been solved

Similar Questions

What will be the output of the program?  Write the answer in digits not alphabets.#include<stdio.h>int main(){    int a=5;    int b=++a*a++;    printf("%d",b);    return 0;}

What will be the output of the following program? Write the answer in digits not alphabets.#include<stdio.h> int main() {     float i=10, *j;     void *k;     k=&i;     j=k;     printf("%.2f", *j);     return 0; }

What will be the output of the following program?

What is the output of the following C Program?

What will be the output of the following program in Python?print(0 or 1)

1/4

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.