Computer Science, asked by psatyam6733, 1 year ago

write a program to convert floating point values into its integral equivalent using pointer

Answers

Answered by mihirkumar3
3
You can do it by using type casting. The syntax is-

Example:

float x;

x=3.14;

int y;

y= (int)x;

printf(“%d”, y);

Output:

3

What really happened? I’ll explain it by taking a famous analogy.

Think of a bucket completely filled with water. Now suppose you have a mug. What is the maximum water you can take out of the bucket? Answer- A mug.

Here the bucket is float (4 bytes), and the mug is int (2 bytes). Type casting is the process of filling, and water (data) is lost while doing so.

Hope this helps;)

Similar questions