Here's some answers, each with a grain of truth, but none of which I suspect your instructor is expecting. To find the real answers I recommend you search through your notes, your book, or, if you must, search the web.
Q.no.1: What is the difference between zero and null values?
zero is a number, NULL is a place
Q.no.2: If we have double data type then why we use long data types?
The number of digits in a number has little to do with the value of the number
Q.no.3: How arrays make coding easy in C++?
There is less typing
Q.no.4: If we are given 1-dimensional array. How can we code through single dimensional array?
What a loopy question.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
This smells like homework, but I'lll try to answer them anyway.
>>Q.no.1: What is the difference between zero and null values?
In c++, none. Most compilers define NULL as 0. Traditionally programmers use NULL for pointers and 0 for numeric objects, but some programmers such as Dr. Bjarne Stroustrup (father of c++ language) never use NULL.
>>Q.no.2: If we have double data type then why we use long data types?
They serve two different purposes. long data types take up less memory and operations on them are faster. longs are just simply more efficient when decimals are not needed.
>>Q.no.3: How arrays make coding easy in C++?
because you can use loops to manipulate arrays, which means less coding then a bunch of individual data items.
>>Q.no.4: If we are given 1-dimensional array. How can we code through single dimensional array?
with a loop.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
And the grains of truth not immediately obvious from Ancient Dragons response:
1) To my knowledge NULL is a memory address that is gauranteed not to have a value associated with it. This address is not dereferenceable. It is often, but (to my knowledge) zero. But then again, my knowledge isn't all encompassing, so maybe NULL is gauranteed to be zero.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
And the grains of truth not immediately obvious from Ancient Dragons response:
1) To my knowledge NULL is a memory address that is gauranteed not to have a value associated with it. This address is not dereferenceable. It is often, but (to my knowledge) zero. But then again, my knowledge isn't all encompassing, so maybe NULL is gauranteed to be zero.
The definition of NULL for C and C++ differs; here is an example from the stddef.h header supplied with MSVC++ 8 (note: cstddef wraps and includes stddef.h in this implementation):
/* Define NULL pointer value */
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
http://en.allexperts.com/q/C-1040/NULL-value-C-C-1.htm
As shown above, in C language NULL is 0 cast to a pointer, while in C++ its just simply 0. Although it might compile without error, I never initialize an integer with NULL because its intent is to be an initializer for a pointer.
Here is another thread I found interesting that gives a little more insite into this topic.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Ancient hits the bulls eye.
Here is a excepts from Stroustrup's homepage: http://www.research.att.com/~bs/bs_faq2.html#null
Should I use NULL or 0?
In C++, the definition of NULL is 0, so there is only an aesthetic difference. I prefer to avoid macros, so I use 0. Another problem with NULL is that people sometimes mistakenly believe that it is different from 0 and/or not an integer. In pre-standard code, NULL was/is sometimes defined to something unsuitable and therefore had/has to be avoided. That's less common these days.
If you have to name the null pointer, call it nullptr; that's what it's going to be called in C++0x. Then, "nullptr" will be a keyword.
For the Q3, strictly speaking in C++, array do not always makes coding easier. std::vector makes coding lot easier than the traditional arrays.
Arrays are the feature of C which is been inherited in C++. If your on C++, try avoiding arrays and use std::vector.
In case the OP is not familiar with std::vector, he may do a little research on them as has to learn them one day or the other.
As far as OP's last question is concerned , I didn't understand it fully to make a remark.
siddhant3s
Practically a Posting Shark
816 posts since Oct 2007
Reputation Points: 1,486
Solved Threads: 140