Information sorts
C has a few sorts of variables, however there are a couple of fundamental sorts:
Numbers - entire numbers which can be both positive and negative. Characterized utilizing burn, int, short, long or long.
Unsigned numbers - entire numbers which must be certain. Characterized utilizing unsigned roast, unsigned int, unsigned short, unsigned long or unsigned long.
Coasting point numbers - genuine (numbers with parts). Characterized utilizing buoy and twofold.
Structures - will be clarified later, in the Structures segment.
The distinctive sorts of variables characterize their limits. A roast can extend just from - 128 to 127, though a long can go from - 2,147,483,648 to 2,147,483,647.
Note that C does not have a boolean sort. As a rule, it is characterized utilizing the accompanying documentation:
#define BOOL burn
#define FALSE 0
#define TRUE 1
Execute Code
C uses varieties of characters to characterize strings, and will be clarified in the Strings area.
Characterizing variables
For numbers, we will more often than not utilize the sort int, which a whole number in the extent of a "word" the default number size of the machine which your project is assembled on. On most PCs today, it is a 32-bit number, which implies the number can go from - 2,147,483,648 to 2,147,483,647 (same as long).
To characterize the variables foo and bar, we have to utilize the accompanying punctuation:
int foo;
int bar = 1;
Execute Code
The variable foo can be utilized, yet since we didn't introduce it, we don't have the foggiest idea about what's in it. The variable bar contains the number 1.
Presently, we can do some math. Expecting a, b, c, d, and e are variables, we can just use also, short and increase administrators in the accompanying documentation, and allot another worth to a:
int a = 0,b = 1,c = 2,d = 3, e = 4;
a = b - c + d * e;
printf("%d", a);/* will print 1-2+3*4 = 11 */
Execute Code
Exercise
In the following activity, you should make a project which prints out the total of the numbers a, b, and c.
Begin Exercise