Data Types

Data Types

Here are some of the basic data types in C:

  1. int: Used to store integers (whole numbers) within a specified range. For example, int num = 10;.
  2. float: Used to store floating-point numbers (real numbers with decimal places). For example, float num = 3.14;.
  3. double: Similar to float, but can store larger numbers with greater precision. For example, double num = 3.14159265359.
  4. char: Used to store a single character. For example, char letter = ‘a’;.
  5. bool: Used to store a boolean value (true or false). For example, bool is_done = false;.

Variables can be used in expressions and assigned new values during program execution. For example:

				
					int num1 = 10, num2 = 5;
 int sum = num1 + num2;                       // sum is 15
 num1 = 20;                                             // num1 is now 20 

				
			

It’s important to note that C is a statically-typed language, which means that the type of a variable must be declared before it can be used, and cannot be changed during program execution.

Join To Get Our Newsletter
Spread the love