Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

1 byte = 8 bit

Data type
1. int : 4 byte range :
2. char: 1 byte -128 to 127
: 0 to 255 for unsigned
: for converting higher values modulo is used 256->0 257->2 ...
3. short : 2 or 4 byte
4. long : 4 byte

The % operator cannot be applied to a float or double .


Increment operator : ++n First increment value then use value
: n++ First use value then increment it

Associativity: Binary : Left to Right


Unary,Ternary,Assignment(Only these three) : Right to Left
Precedence:
Unary
Arithmatical
Relational
Bitwise
Logical
Ternary
Assignment
Comma

operators typecast everything to int or higher.


scanf returns the number of inputs it has successfully read.
Precedence of , is the lowest.
In C when we initialize less no of elements in an array all uninitialized elements
become ‘\0’ in case of char and
0 in case of integers.
element of array can also be accessed using index[array] along with array[index].
brackets have the highest precedence.

printf("%5d") ensures that width of the output will be greater than or equal to 5.
floa holds six decimal digits.printf adds 0s if the number has less that 6 digits
after the deciaml point.
printf("%12.4f") ensures that "total"(all digits) minimum width is 12 and number of
digits displayed after the deciaml are 4.
printf("%2.7s") ensures that minimum length is 2 and maximum length is 7. if
something invalid like ("4.3s") is given then it only ensures the minimum length 4.
printf("2.4%d") prints 4 character wide integer paddded with 0 because deciaml
digits for integers doesn't make sense.

switch case:
The case statement only acts as label. If none of the cases matches then the code
goes to the default label and everything after that is executed
Case expression must be a constant or a macro constant. It cannot be a variable.

printf returns the width of the printed text, scanf returns the number of inputs it
reads.
sizeof is a comile-time operator. Any operator used inside sizeof doesn't get
evaluated.
while printing strings printf(2+"ABCDEF") prints DEF

You might also like