1. Types Data Types
Basic Data Type int,char, float,double
DerivedDataType array, pointer,structure,union
EnumerationDataType enum
VoidData Type void
Type Storage size Value range
char 1 byte -128 to 127 or 0 to 255
unsignedchar 1 byte 0 to 255
signedchar 1 byte -128 to 127
int 2 or 4 bytes
-32,768 to 32,767 or -2,147,483,648 to
2,147,483,647
unsignedint 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsignedshort 2 bytes 0 to 65,535
long 8 bytesor (4bytesfor32 bitOS) -9223372036854775808 to 9223372036854775807
2. unsignedlong 8 bytes 0 to 18446744073709551615
Type Size (bytes) Format Specifier
int at least2, usually4 %d,%i
char 1 %c
float 4 %f
double 8 %lf
short int 2 usually %hd
unsignedint at least2, usually4 %u
longint at least4, usually8 %ld,%li
longlongint at least8 %lld,%lli
unsignedlongint at least4 %lu
unsignedlonglongint at least8 %llu
signedchar 1 %c
unsignedchar 1 %c
longdouble at least10, usually12 or 16 %Lf
3. intid,age;
floatsalary;
double price;
longa;
longlongb;
longdouble c;
KeywordsinC
A keywor d isa reservedword.You cannot use it as a variable name,constantname,etc.
There are only32 reservedwords(keywords) in the Clanguage.
A listof 32 keywordsinthe c language isgivenbelow:
auto break case char const continue default do
double else enum extern float for goto if
int long register return short signed sizeof static
struct switch typedef union unsigned void volatile while
There are followingtypesof operatorstoperformdifferenttypesof operationsinClanguage.
1. ArithmeticOperators
2. Relational Operators
3. ShiftOperators
4. Logical Operators
5. Bitwise Operators
6. Ternaryor ConditionalOperators
7. AssignmentOperator
8. Misc Operator
4. ArithmeticOperators
The followingtable showsall the arithmeticoperatorssupportedbythe Clanguage.Assume
variable Aholds10 and variable Bholds20 then−
Operator Description Example
+ Addstwooperands. A + B = 30
− Subtractssecondoperandfromthe first. A − B = -10
* Multipliesbothoperands. A * B = 200
/ Dividesnumeratorbyde-numerator. B / A = 2
% ModulusOperatorand remainderof afteranintegerdivision. B % A = 0
++ Incrementoperatorincreasesthe integervaluebyone. A++ = 11
-- Decrementoperatordecreasesthe integervalue byone. A-- = 9
Relational Operators
The followingtable showsall the relational operatorssupportedbyC.Assume variable Aholds10
and variable Bholds20 then−
Operator Description Example
== Checksif the valuesof twooperandsare equal or not.If yes,thenthe condition
becomestrue.
(A == B)
isnot
true.
!= Checksif the valuesof twooperandsare equal or not.If the valuesare not equal,
thenthe conditionbecomestrue.
(A != B)
istrue.
5. > Checksif the value of leftoperandisgreaterthanthe value of right operand.If yes,
thenthe conditionbecomestrue.
(A > B) is
not
true.
< Checksif the value of leftoperandislessthanthe value of rightoperand.If yes,then
the conditionbecomestrue.
(A < B) is
true.
>= Checksif the value of leftoperandisgreaterthanor equal to the value of right
operand.If yes,thenthe conditionbecomestrue.
(A >= B)
isnot
true.
<= Checksif the value of leftoperandislessthanor equal tothe value of right operand.
If yes,thenthe conditionbecomestrue.
(A <= B)
istrue.
Logical Operators
Followingtableshowsall the logical operatorssupportedbyClanguage.Assume variable Aholds1
and variable Bholds0, then−
Operator Description Example
&& CalledLogical ANDoperator.If boththe operandsare non-zero,thenthe condition
becomestrue.
(A &&
B) is
false.
|| CalledLogical OROperator.If any of the twooperandsisnon-zero,thenthe
conditionbecomestrue.
(A || B)
istrue.
! CalledLogical NOTOperator.Itis usedtoreverse the logical state of itsoperand.If a
conditionistrue,thenLogical NOToperatorwill make itfalse.
!(A &&
B) is
true.