Join our subscribers list to get the latest news, updates and special offers directly in your inbox
Overview
Data Types
Operators In C
Macros
In C programming, a variable is used to store the data. Data types are used to define the type of a variable. The most commonly used data types in C are int (integer), char (character), float (floating point number), and double (double precision floating point number).
Understanding the data is important as it impacts the way it is stored or retrieved from memory. Data types can affect the memory usage, speed, and accuracy of your program.
Integers are used to represent whole numbers without decimal points. In embedded C, several integer types are available, including:
Embedded C programming also offers fixed-width integer types provided by the header
Here are some commonly used fixed-width integer types, these are present in the #include :
int num = 0; unsigned int num = 1;short int num = 2;unsigned short int num = 3;long int num = 4;unsigned long int num = 5;int8_t num = 6;uint8_t num = 7;int16_t num = 8;uint16_t num = 9;int32_t num = 10;uint32_t num = 11;int64_t num = 12;uint64_t num = 13;
Floating-point types are used to represent real numbers, including numbers with decimal points. The two commonly used floating-point types in embedded C are:
float fl = 1.1F;double dl = 1.2F;
A bool * pointer is used to store the memory address of a bool variable. By utilizing a bool * pointer, we can access and manipulate the value of a bool variable indirectly. #include header file is a standard C library header that provides the necessary definitions for using the bool type
bool
bool num = true;
Pointer types are used to store memory addresses, allowing access to data located at those addresses. Some common pointer types include:
This type of data is used to store single characters like letters, symbols, or numbers. The char keyword represents this data type in C.
char ch = 'a';
This type of data is a collection of variables with the same data type and is ideal for storing multiple values of the same type.
int arr[5] = {1, 2, 3, 4, 5};char ch_arr[5] = {'A', 'B', 'C', 'D', 'E'};
This data type enables you to group variables of different data types into a single unit, making it useful for storing data related to a single entity such as a person or object.
struct num_s { int one; char two; float three;}; struct num_s num;num.one = 1;num.two = '2';num.three = 3.00F;
EmbeddedWala Jun 14, 2023 0 21.7K
EmbeddedWala Apr 27, 2023 0 21.1K
EmbeddedWala Apr 26, 2023 0 18.5K
EmbeddedWala Aug 30, 2022 0 16.6K
EmbeddedWala Apr 27, 2023 0 16.5K
EmbeddedWala Jun 19, 2022 0 4.8K
This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies Find out more here