İçerikler
C Programming Variables
Almost all programming languages have variable types. And of course, there are a few data types that we use when programming C. There are 4 data types in the C programming language. In this tutorial i will teach you declare and use the variabls. More tutorial on my web site check it! And you can watch my c tutorials videos from here . If you ready let me teach you c programming variables.
Syntax For Using Variables
DATA_TYPE variable_name
Example : Int x =5 or char float f = 5.3;
The C programming variables are as follows.
Integers – int (0, 1, 10, -1 ,-58)
Characters – characters (a, b, x)
Logically – false == 0, true!= 0
Fractional Numbers – float, double (0.5, 0.24, 1.258)
Structural Types – array, string, functions, structure, files, pointers
Let learn how to declare and use INT
In the following code, we have defined a variable called “number” as INT. In the next line, we assigned the variable “number” to 5. Thus, when we call this variable in the following lines, it will come to us as 5.
#include <stdio.h> #include <stdlib.h> int main() { int number; number=5; printf("%d \n",number); return 0; }
How to define a char variable? Antoher C Programming Variables
Below, we have defined a char variable and given this variable the letter A so that when we call this variable in the program, the letter a will appear.
#include <stdio.h> #include <stdlib.h> int main() { char c='A'; printf("%c \n",c); return 0; }
How to define a float variable?
Float is a variable used for decimal numbers. In the following code, we defined a float variable called f and assigned the value 1.5. In the next stages, when we call the variable f, we will see the number 1.5. As an example, when we print to the screen with the printf function, we will see 1.5.
#include <stdio.h> #include <stdlib.h> int main() { float f=5.1; printf("%f ",f); return 0; }