answersLogoWhite

0

The question is not clear. If you mean can you write a C++ program such that the main function returns a boolean, the answer is no, you cannot. The main function must return an int to the operating system. However, the return value can be treated as boolean such that non-zero indicates true (an error has occurred) and zero indicates false (no error).

Unlike C, C++ does include a primitive bool data type which can only be true or false. All the comparision operators such as ==, !=, <, <=, > and >= return bool and all the integral data types (int, char, wchar_t) can be implicitly converted to and from bool. Converting a bool to an int returns the value -1, since false is typically imlemented with all bits set while true is implemmented with all bits unset.

User Avatar

Wiki User

10y ago

What else can I help you with?

Related Questions

How do you get boolean value from string in java?

Here is some sample code to convert a string into a boolean: String word = "true"; boolean boo; if (word.equalsIgnoreCase("true")) boo=true; else boo=false;


How do you show the text box output in the browser using Ajax code?

You can directly do that in the JavaScript. Just get the value of the input type in JavaScript using id and show it using .innerHTML.


What is a Boolean condition?

A boolean is a value which can either be true or false. A boolean condition is mathematical equation where the result is a boolean (either true or false). Often used in programming.A boolean condition consists of some varibles, and boolean operations that can be carried out using them. Here are some boolean operations. The sybols are those used in Java and C++.> Greater Than. Returns true when the number before > is greater than the number after< Less Than. The opposite of Greater than== Equals. If the values are equal returns trueOR Returns true if the boolean before and/or the boolean after is true&& AND Returns true only if the boolean before AND after the && are true! NOT Inverts/NOT's a boolean. True becomes false. False becomes trueMost programming languages have booleans as a type of variable and if statements as control flow.An if statement uses a boolean to decide whether or not something is run eg.if(someBoolean){// If some boolean is true this peice of code will be run}A an example of a boolean condition could use a less than or greater than symbolif( someNumber > 9000 ) {print( "The number... it's.... OVER 9000!!" );}


What is the definition of boolean?

Exampe of Boolean and usage in the real word Operators Operator = Equal to != ^= Not equal to &lt; Less than Greater than &gt;= Greater than or equal to is null Value is null is not null Value is other than null like Value is an instance of pattern-matching string not like Value is not an instance of pattern-matching string Condition is a Boolean value (&quot;Petar&quot; === &quot;John&quot;) //This is false (&quot;Petar&quot; === &quot;Petar&quot;) This is true if (condition) { code to be executed if condition is true; }


How can you handle a situation where you cannot return a value from a method with a void result type?

In a situation where you cannot return a value from a method with a void result type, you can use other methods such as setting a global variable or using output parameters to pass the value back to the calling code.


What is Boolean means in Visual BASIC?

Boolean refers to values that can only be True or False. If you are setting up a boolean variable, only True or False can be stored in it. This is a standard element of programming languages for situations involving options for True/False, Yes/No etc. When you see something in a program like "Do you want to continue (Yes/No)?", the reply given is stored as a boolean value. They can be referred to as logical values. The term boolean comes from the mathematician George Boole, after whom they are named.


How do you know the value of a capacitor?

The value is usually marked on it, either using color code or digits.


Difference between measured value using multi-tester and color code value using resistor color coding?

(coded value - measured value) /coded value x 100


Why would you use code generation?

Using code generation is simpler and faster than manually creating code. For example, if I had an xml schema and wanted to output as c++ or java or c#, it would take forever to code manually. Using a tool is faster and easier.


Advantages of Typeless programming language?

* In a typeless language, a variable can contain any kind of value (numeric, string, boolean). * Typeless languages are very flexible and dynamic, resulting in quick turn around of code.


Is a bar code printer input or output?

A bar code printer or any kind of printer is an output device.


Can you have a boolean data type array?

Yes, you can have a boolean data type array. In programming languages such as Python, Java, and C++, you can create an array (or list) that stores boolean values, typically represented as true and false. This allows you to manage collections of binary states efficiently, such as flags or conditions in your code.