Skip to main content

basics of C

operators

operatorprecedenceassociativity
()1 highleft to right
power2right to left
* / %3left to right
+ -4L - R
=5 lowR - L

Associativity
if 2 or more operators have same precedance then the expression will be evaluated by using Associativity

Relational and Logical operators

  • "\0", 0, null are False
  • 1 is true
  • assiciativity left to right

modulus operator (%)

  1. modulus always gives numerator sign
  2. mod dosen't work on float values
  3. if value is small withghout sign it gives same value as output

Scanf()

scanf return int, it return no. of proper inputs given according to format spicifier

Ternary operator

(condition)?True:False(condition)\, ? \, True \, : \, False
  • in ternary operator no. of ? == : otherwise gives error
  • every colon should match just before Question mark
  • every ? followed by : not immediatly but following

good program & bad program
program should work on logic not on compiler increment same variable multiple times in a single line is a bad program