C Language – Types of primitive data

C Language
C Language


What are the variables?


We must imagine the variables as the drawers of our bedside table, where we can put the things we want to save temporarily.


There are various types of variables, those mainly used are integer variables “int” where integer numbers are saved, “char” character variables where all the characters are saved (from the alphabet to particular characters like @ #., …… ….) And variables of real numbers “float” where the real numbers are saved with the decimal part.


How are the variables declared?


The variable name must be written in lowercase and can take any name. It is always better to give names that indicate what those variables are.


int number=0;


char character;


float decimal_number=0;


Now let’s try to give values to these keyboard variables.


To give values, use the “scanf ()” function.


If we want to save an integer number we have to write “scanf (“%d”, &number); “


%d indicates that we must save an integer, &number (where number and the name of our variable) indicates that the whole number that we input from the keyboard will save it in our variable.


Instead, to save a character, use “%c” and to save a decimal number “%f”.


Also to display the variables on the screen then you have to tell the printf what type of variable it should print and its name.


Example printf (“%d”, number);


C Language


More information


By entering ” // ” the line will turn green and is a comment line where you can write on that line all the time the compiler will skip it.


As you can see from the photo in the printf I inserted the “ \n “ tab that indicates to go to the next line to view.


Stay Tuned!


Salve, sono un ragazzo di 25 anni, iscritto alla facoltà di informatica, appassionato di programmazione e delle nuove news tecnologiche in ambito informatico.

Related Posts

This site uses Akismet to reduce spam. Learn how your comment data is processed.