Type bool

Variables of type int can have billions of possible values, and those of type char can have 256. Variables of type bool can have only two possible values: true and false. In theory a bool type requires only one bit (not byte) of storage, but in practice compilers often store them as integers because an integer can be quickly accessed, while an individual bit must be extracted from an integer, which requires additional time.

Type bool is most commonly used to hold the results of comparisons. Is alpha less than beta? If so, a bool value is given the value true; if not, it’s given the value false.

Type bool gets its name from George Boole, a 19th century English mathematician who invented the concept of using logical operators with true-or-false values. Thus such true/false values are often called Boolean values.

Read more...

Character Variables and Character Constants

Character Variables
Type char stores integers that range in value from –128 to 127. Variables of this type occupy only 1 byte (eight bits) of memory. Character variables are sometimes used to store numbers that confine themselves to this limited range, but they are much more commonly used to store ASCII characters.

Complexities arise when foreign languages are used, and even when programs are transferred between computer systems in the same language. This is because the characters in the range 128 to 255 aren’t standardized and because the one-byte size of type char is too small to accommodate the number of characters in many languages, such as Japanese. Standard C++ provides a larger character type called wchar_t to handle foreign languages. This is important if you’re writing programs for international distribution. However, in this book we’ll ignore type wchar_t and assume that we’re dealing with the ASCII character set found in current versions of Windows.

Character Constants
Character constants use single quotation marks around a character, like ‘a’ and ‘b’. (Note that this differs from string constants, which use double quotation marks.) When the C++ compiler encounters such a character constant, it translates it into the corresponding ASCII code. The constant ‘a’ appearing in a program, for example, will be translated into 97.

Escape Sequences
This second character constant, ‘\t’, is an odd one. Like ‘\n’ which we encountered earlier, it’s an example of an escape sequence. The name reflects the fact that the backslash causes an “escape” from the normal way characters are interpreted. In this case the t is interpreted not as the character ‘t’ but as the tab character. A tab causes printing to continue at the next tab stop. In console-mode programs, tab stops are positioned every eight spaces. Another character constant, ‘\n’, is sent directly to cout in the last line of the program.

Read more...

C Vs C++

Here comes a very long debate and queries and doubts.

What are the similarities and differences between C and C++ ??

Why C++ gained popularity ??
(Even though C++ gained popularity, still C is used professionally because of its simplicity)

What made you to come here to know the advantages of C++ over C ?

Read more...

What Is Cplusplus ?

Cplusplus is an object oriented programming language much more advantageous and complexity involved when compared to the C language. Cplusplus is generally abbreviated as C++, herein consider like this. Sometimes some professional will short code as Cpp.

As mentioned above all the concepts in the C++ are centered around the objects, we will see later what are the objects actually

Read more...

  © Free Blogger Templates Modic Template by For more Information : click Here

Back to TOP