Search⌘ K
AI Features

Discussion: What is Nothing?

Discover the differences between zero, negative zero, NULL pointers, and the null character in C programming. Learn how these concepts are represented in memory and their implications in coding, enhancing your understanding of C fundamentals and preventing common programming confusions.

Run the code

Now, it's time to execute the code and observe the output.

C++
#include <stdio.h>
int main()
{
float n, p;
n = -0.0;
p = +0.0;
if( n==p )
printf("negative zero is equal to positive zero\n");
else
printf("negative zero is not equal to positive zero\n");
return(0);
}

Understanding the output

The code compares negative and positive zero as created by the compiler and stored in memory:

negative zero is equal to positive zero
Code ouput

Zero:

...