HomePublic NotesNote detailsFlashcards

Flashcards for:

Fundamental Data Types in C++

Can void be used to define a variable?

Press to flip

No, void cannot be used to define a variable, but it can be used as a function return type.

What is a data type in C++?

Press to flip

A data type tells the type and size of data a variable can hold.

What are fundamental data types in C++?

Press to flip

Fundamental data types are built-in and predefined data types like int, char, float, double, bool, and void.

What is the size and range of the int data type?

Press to flip

Size of int is 4 bytes (32 bits) and range is from -2147483648 to 2147483647.

What formula is used to find the signed range of an integer type?

Press to flip

The formula is -2^(n-1) to +2^(n-1) -1, where n is the number of bits.

What is the unsigned range formula for integer types?

Press to flip

The formula is 0 to 2^n -1.

What is the range of a signed short int in C++?

Press to flip

The range is -32768 to 32767.

What is the range of an unsigned short int in C++?

Press to flip

The range is 0 to 65535.

What is the size and range of the long long int type?

Press to flip

Size is 8 bytes (64 bits) with a range of -2^63 to +2^63 - 1.

What is the size of the char data type?

Press to flip

The size of char is 1 byte (8 bits).

What is the range of signed and unsigned char types?

Press to flip

Signed char ranges from -128 to 127, unsigned char ranges from 0 to 255.

What influences whether char data type is signed by default?

Press to flip

It depends on the compiler. Some may default to signed char, others to unsigned char.

What is the size and precision of the float data type?

Press to flip

Float has 4 bytes size (32 bits) and precision up to seven decimal digits.

What is the range of float data type values?

Press to flip

Float type range is 1.17549E - 38 to 3.40282E + 38 for positive values.

What is the significance of precision in float data type?

Press to flip

Float provides precision up to seven decimal digits, meaning values can be accurately represented up to seven digits after decimal.

What is the size and precision of the double data type?

Press to flip

Double has a size of 8 bytes and precision up to 15 decimal digits.

What is the range of values for the double data type?

Press to flip

Range is 2.22507E - 308 to 1.79769E + 308 for positive values.

What is the bool type used for?

Press to flip

Bool is used to represent truth values, true and false.

What is the size of the bool type?

Press to flip

Size of bool type is one byte (8 bits).

What does the void data type represent?

Press to flip

Void indicates the absence of data or no value.

Can void be used to define a variable?

Press to flip

No, void cannot be used to define a variable, but it can be used as a function return type.

What is a data type in C++?

Press to flip

A data type tells the type and size of data a variable can hold.