Numeric, character and boolean data types - C++

Explain numeric, character and boolean data types.

Various data types in C++ :

Numeric :
- This is a fundamental type provided by C++ language. Integers, Floating point types come under this.

Boolean :
- Can have one of the two values, true or false. It is used to express the results of a logical operations. They are internally stored as number. A non-zero value is considered true whereas zero is false.
- Example :
Void f(int x, int y)
{
   Bool b;
   If (x == y)
   b = true;
}
- Thus, value of b becomes true if x equals y.
- A common use of bool is as the type of the result of a function that tests some condition.
- For example :
bool isopen(File *fp);
Character :
- A variable of type char can hold any character of the implementation’s character set. It takes 1 byte of storage and it can hold 256 different values.
- For example :
char c = ‘a’;
- Since character types are integral types, arithmetic and logical operations apply on them.

When do you use bool data type?

- The bool data type can take only two values true or false.
What is Typecasting? Explain with examples.
Typecasting: C++ is very strict about type compatibility. Different variable types must be cast when their values are assigned to each other.
Explain (scope resolution operator) :: operator with an example - C++
Explain :: operator with an example - :: Operator: ‘::’ is known as Scope Resolution Operator...
What is const qualifier? - C++
What is const qualifier? - The qualifier const can be applied to the declaration of any variable to indicate that its value will not be changed.....
Post your comment