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; }
Solution
The output of the program will be 10.00.
Here's the step by step explanation:
- A float variable
iis declared and initialized with the value 10. - A float pointer
jand a void pointerkare declared. - The address of
iis assigned to the void pointerk. - The void pointer
kis assigned to the float pointerj. This is possible because a void pointer can hold the address of any data type. - The value at the address held by
jis printed, which is the value ofi, i.e., 10.00. The "%.2f" in the printf statement is used to print the float value up to 2 decimal places.
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)
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.