C language learned by suffering
C language learned by suffering
Variable Type
data type
In the previous section, we discussed variable declarations and their usage.
When declaring a variable, we have explained little about its type.
In the previous section, we explained that to declare a variable, use the following writing style
A type name is an example of the type of number you want to remember.
In the previous section, we used int to store integers, but
There are many other types of this type.
The C language can handle many different types of numbers.
And for each number, a separate type of variable must be used to store it.
These different types of numbers are sometimes referred to as data types.
In C, each of those types is named separately.
And the names are often referred to as what-types.
When declaring a variable, we have explained little about its type.
In the previous section, we explained that to declare a variable, use the following writing style
Declare variables
Type name Variable name;
A type name is an example of the type of number you want to remember.
In the previous section, we used int to store integers, but
There are many other types of this type.
The C language can handle many different types of numbers.
And for each number, a separate type of variable must be used to store it.
These different types of numbers are sometimes referred to as data types.
Keywords.
[Data type
A type of numerical value. The maximum number of digits, whether it is an integer or a real number, and so on.
In C, each of those types is named separately.
And the names are often referred to as what-types.
Variable to store real numbers
There are not many types of data types used in the C language.
For the time being, you only need to remember the following two.
The variable we just used was of type int.
Apart from that, another type of variable called double (double) type can also be used.
While type int stores integers, type double stores real numbers.
The following program is an example of using the double type to perform four arithmetic operations.
The result of executing this program will be as follows
If you compare it with the previous program, you will see that the usage is exactly the same.
For the time being, you only need to remember the following two.
Type name | Numeric Type |
---|---|
int | integer |
double | real number |
The variable we just used was of type int.
Apart from that, another type of variable called double (double) type can also be used.
While type int stores integers, type double stores real numbers.
The two are used in exactly the same way, just for different types of numbers to be stored.
The following program is an example of using the double type to perform four arithmetic operations.
Source Code
#include <stdio.h>
int main(void)
{
double left, right;
left = 10;
right = 3;
printf("%f\n", left + right);
printf("%f\n", left - right);
printf("%f\n", left * right);
printf("%f\n", left / right);
return 0;
}
The result of executing this program will be as follows
Execution Result
13.000000
7.000000
30.000000
3.333333
7.000000
30.000000
3.333333
If you compare it with the previous program, you will see that the usage is exactly the same.
About this Site
The C language (bitter C), which is learned by suffering, is
This is the definitive C language introductory site.
It systematically explains the basic functions of the C language and
It is as complete as or more complete than any book on the market.