Why is it important to put the value of zero when declaring a variable and in c++, whats the purpose of return 0? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why is it important to put the value of zero when declaring a variable and in c++, whats the purpose of return 0?

24th Feb 2017, 1:36 PM
Allen Villanueva
Allen Villanueva - avatar
2 Answers
+ 3
Wow! Thanks sir for your answer. Now i understand :D
24th Feb 2017, 2:17 PM
Allen Villanueva
Allen Villanueva - avatar
+ 1
it is not much important to declare a variable as zero when u are using it like int d; d=k; where k is some another number in your code here no need to declare it as zero or when u r using like int d=0; d=d+k; here u need to declare it as 0 in the starting or else it may assign an random value itself which gives u an error in the output finally i suggest u to declare a value as zero so that most of the times no error is printed in the same way we use return 0; at the end of the code
24th Feb 2017, 2:11 PM
chandan reddy
chandan reddy - avatar