0% found this document useful (0 votes)
8 views2 pages

Define Datatype

Data types specify the type of data that can be stored in variables and include integer, floating-point, character, and boolean types. Integer types represent whole numbers, floating-point types represent numbers with decimals, character types represent individual characters, and boolean types represent true or false values. There are also derived types like arrays, pointers, structures, and unions that are constructed from fundamental types.

Uploaded by

salmangadyali123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Define Datatype

Data types specify the type of data that can be stored in variables and include integer, floating-point, character, and boolean types. Integer types represent whole numbers, floating-point types represent numbers with decimals, character types represent individual characters, and boolean types represent true or false values. There are also derived types like arrays, pointers, structures, and unions that are constructed from fundamental types.

Uploaded by

salmangadyali123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Q.

5:- Define datatype in details

**Data Types**:

In programming, data types specify the type of data that can be stored and manipulated in
variables. Each data type has specific characteristics, including the range of values it can
represent, the memory size it occupies, and the operations that can be performed on it.

**Integer**: Integer data types represent whole numbers without any fractional part. They
can be further classified based on their size, signedness (whether they can represent
negative values), and range of values. Common integer types include `int`, `short`, `long`,
and their variations like `unsigned int`.

**Floating-Point**: Floating-point data types represent real numbers with a fractional part.
They can store decimal values and are used for calculations requiring precision. Common
floating-point types include `float`, `double`, and `long double`, each providing different
levels of precision.

**Character**: Character data types represent individual characters such as letters, digits,
or symbols. In C programming, characters are represented using the `char` data type, which
typically occupies 1 byte of memory.

**Boolean**: Boolean data types represent logical values indicating true or false. In
languages like C, boolean values are often represented using integers, where `0` represents
false and any non-zero value represents true. However, some languages have dedicated
boolean data types like `bool` in C++.

**Derived and User-Defined Types**: Derived data types are constructed from fundamental
types or other derived types. Examples include arrays, pointers, structures, and unions.
User-defined types are types defined by the programmer using derived types or other user-
defined types.

**Example**:

```c

#include <stdio.h>

int main() {

int age = 30; // Integer data type

float height = 5.8; // Floating-point data type

char grade = 'A'; // Character data type


_Bool isStudent = 1; // Boolean data type (represented as integers in C)

printf("Age: %d\n", age);

printf("Height: %.1f\n", height);

printf("Grade: %c\n", grade);

printf("Is Student: %d\n", isStudent);

return 0;

```

In this example:

- `age` is an integer variable storing the age of a person.

- `height` is a floating-point variable storing the height of a person.

- `grade` is a character variable storing the grade of a student.

- `isStudent` is a boolean variable indicating whether the person is a student or not.

You might also like