difference between null and zero!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahulkumar200
    New Member
    • Apr 2015
    • 1

    difference between null and zero!

    hello everybody ,
    I need to know the right and correct difference and similarity between ZERO AND NULL !
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    who knows?

    The way to find out what NULL is to look in your stddef.h header and see. NULL is not part of C but is, instead, a defined constant. In C++ NULL is deprecated.

    Do not assume NULL is 0. If you mean 0 then use 0. You see, NULL could be and int 0 or it could be a char \0.

    Personally, I have never used NULL.

    I have never heard of ZERO.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      Suppose you have two constants in your program: one of them is CentimetersPerI nch and the other is DistanceHomeToW orkKilometers; and they happen to both be equal to 2.54. These are two very different things despite them happening to have the same value.

      What have you been taught about NULL?

      Comment

      • MonikaSR
        New Member
        • Apr 2015
        • 3

        #4
        Zero is a unique value and known quantity of zero, which is meaningful in arithmetic and math.
        Null is a non-value. It takes only the place for that value which is not specified or not known. And mathematical operation cannot be done with Null value.
        In computers when we done operation on a null variable it will result in null value or either shows an error condition. Because the variable value is not known so the result of the expression is not known.
        More clearly understand by taking an example: Someone ask to you, what is your yearly income? Its answer must contains a numeric value like “0” which is perfect and valid answer who has no investment and does not work. And if you tell this to your software you do not enter any value because the value is not specified. So, to allow the software to continue you put “Null” value to fill that place.

        Comment

        • HenilGandhi
          New Member
          • May 2015
          • 1

          #5
          zero (0) is a number, and NULL is a value that represents "no value". As such, 0 can be added, subtracted, etc., but NULL cannot.

          Comment

          • donbock
            Recognized Expert Top Contributor
            • Mar 2008
            • 2427

            #6
            The token NULL is well-defined in the C Standard. It is a value that can be assigned to any data pointer or that any data pointer can be compared against. A pointer whose value is NULL does not currently point to anything. Dereferencing a NULL pointer is undefined behavior.

            Alhough the concept of a null value for other types of variables is conceptually similar to NULL pointers, there is no support for them in the C Standard. Support for no-value-entered-in-this-field is ad hoc.

            Comment

            Working...