Search posts

c programming for Linux 2 – data type

In c variable has data type, that define the type of data they contain.
C data type are very similar to java primitive. For integer number we are using the data type int.
int is 4 byte in size and contain only whole number.
Let see an example:

So we have declare an int number variable white the name k.
Then we assign to it the number 24.
Eventually we print it, the “%d” in the printf mean decimal, and after the comma, we tell it that it should be k, so it will print:value of k = 24
c allow us to do mathematical calculation * is used for multiply, / is used to divided it to the largest integer that give a result equal or small from the number.

Example of program and output of the execution, the program code is between the “===”

char is anther data type in c. It used to contain one charter, and when we want to do an assign we should use single quote ‘ and not double. Inside the printf if we want to print char we use %c (c short for char).