answersLogoWhite

0


Best Answer

The return statement "returns" control to the function that invoked the function executing the return statement. Adding a value, such as return 0, adds a "return value", which the invoking function can inspect. The type of the returned value is declared along with the function's declaration, such as int myfunction(...) - it can be any type, not just an int.

If the "invoking function" is the operating system, the return statement returns control back to the operating system. The value of the return, in this case an int, tells the operating system what the result of the execution of the entire program was.

By convention, but this is operating system, shell, and/or programmer determined, a return value of 0 normally means "success", while anything else means "some kind of error", and the actual value identifies what kind of error.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

It literally means -48. We use this convention whenever we want to convert a character or string representing a whole number to an actual number.

The character '0' is actually represented by the ASCII character code 48 decimal, or 0x30 in hexadecimal. Thus the following declarations are effectively the same:

char chr = '0';

char dec = 48;

char hex = 0x30;

In the ASCII character set, the characters '0' through '9' have character codes 48 through 57 decimal (0x30 through 0x39 hexadecimal). This is quite convenient as it allows us to convert these character codes to their actual digits, simply by subtracting 48 from the character code.

char nine = '9'; // nine = 57

nine = nine - 48; // nine = 9

Rather than trying to remember the number 48, it's more convenient to use the character code indirectly, via the constant literal '0'. The compiler takes care of the conversion for us, so there's no loss in performance whichever way you do it.

char eight = '8'; // eight = 56

eight = eight - '0'; // eight = 8

Of course C/C++ has a built-in subtract and assign operator, so you will typically see this type of conversion written as follows:

char seven = '7'; // seven = 55

seven -= '0'; // seven = 7

Once we can convert an individual numeric character to its equivalent numeric value, it's fairly simple to convert a string of digits to an integer. All we have to do is multiply each digit by an increasing power of 10, from the right, and add them all together.

char * str = "12345";

int number = 0;

int power = 1; // the right-most column is 10^0, which is 0, but we can't multiply by 0, so we start with 1.

int len = 5

while(len--)

{

number += ( str[i] - '0' ) * power;

power *= 10; // increase the power by 10.

}

printf( "%d", number );

Output: 12345

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the meanig of return 0 in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Show the simple c plus plus program?

int main (void) { puts ("Hello, world"); return 0; }


How do you make a message box in c plus plus?

#include<windows.h> int main() { MessageBox(0,"Hello","Welcome Message",1); return 0; }


Why is it important to check the return status when opening a file in c plus plus?

The return value tells you if any errors occurred. A value of 0 typically indicates no error.


Any program in c plus plus without using any header file?

For example: int main (void) { return 0; }


What is C plus 0?

c + 0 = c


Sample programs in c plus plus language using pointers?

#include int main (int argc, char **argv){int i;for (i=0; i


How do you write a programme to print a plus bi in c plus plus?

#include <iostream> int main() { std::cout << "a plus bi" << std::endl; return 0; }


Fundamental components of a c plus plus program?

#include <iostream> using standard namespace std; int main() { cout << "your prob shouldn't be taking c++"; return 0; }


Where is the Example of a c plus plus code?

#include<iostream> int main() { std::cout << "Hello world!" << std::endl; return(0); }


What is the answer to A plus B plus C equals A times B equals C?

A=0 b=0 c=0


Program for 7 table in c plus plus?

#include<iostream> int main() { for(int i=0; i<=12; ++i ) std::cout<<"7 x "<<i<<" = "<<7*i<<std::endl; return(0); }


Write any small program that will compile in C but not in C plus plus?

#include int main (void){char new [3] = "NEW";printf ("new='%.3s'\n", new);return 0;}in C++:int main (void){char newstr [4] = "NEW";printf ("new='%.3s'\n", newstr);return 0;}