Advertisement
Mukezh

Session 2 Keyword Operator

Dec 2nd, 2020 (edited)
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. Constants
  2.  
  3. Integer Constants (int) 5 62 64 0 -78 45 -46 +ve number, -ve number , Zero
  4. Real Constant (float) 3.75 8.54 -5.3 -0.2
  5. Character constant (char) '5' 'a' 'V' '4' '+' '*' '9'
  6.  
  7. Pi = 22/7= 3.14285714286.......... ---> floating Value
  8.  
  9.  
  10. 3.56 float Crt
  11. 'a' char crt
  12. 176 int Crt
  13. '125' char Error ' '=> Length within single quotes is 1
  14. 'name' char Error
  15. '95.5' char Error
  16. a int Error
  17. mukesh int Error
  18. .954 float Crt
  19.  
  20.  
  21. 'ad' error
  22. 34.3 float
  23. Me Error
  24. '0' Char
  25. '10.2' Error
  26.  
  27.  
  28. Normal Language C Language
  29. Alphabets Keywords-> int(integer) char(character) float(floating value)
  30. Words Meaning Operators -> + - * / [45->Operators]
  31. Sentence [Full stop] Seperators -> ; : {} ()
  32. Grammar --> Rules & Regulations Syntax-> format, Error
  33.  
  34.  
  35. What is a Keywords ?
  36. Keywords are Reserved or a predefined words it has a special Meaning. int(integer) char(character) float(floating)
  37. Ex: int ---> it represents Positive, Negative number and Zero
  38. char --> Character constants with ' ' Single quotes, with a length Only one
  39. Valid 'a' 'B' '2' '+'
  40. Invalid 'hello' '123' '1.2'
  41.  
  42. Variables
  43.  
  44. Maths
  45. 4x+2y=0 -> Equation
  46. 4x+2y -> Expression
  47. 4 -> Constant
  48. 2 -> Constant
  49. x -> Variable
  50. y -> Variable
  51. + -> Addition(Operation), Plus(Symbol)
  52. = -> is Equal to (Symbol) , Assignment(Operator)
  53.  
  54.  
  55. Assignment Operator (=)
  56. Conditions
  57. 1. It requires 2 argument Ex: a = 5
  58. 2. Left Side Argument must be variable. Ex: a = 6
  59. 3. Right Side Argument might be Variable (a=b), constant(a=5), Expression(a=5*2)
  60. 4. Left Side Argument is called L-Value a=12 a-> L-Value Error: lvalue required
  61.  
  62. a=7 Invalid semi colon (;) is must
  63. a=5; Valid
  64.  
  65. a=2; a-> 2 b->3 c-> 6
  66. b=3;
  67. c=2+4;
  68.  
  69. a = ; Error Expression syntax error
  70. = b; Error
  71.  
  72. Assignment Left Arg = Right Arg
  73.  
  74. a=5; a-> 5 7
  75. b=7; b-> 7 8
  76. c=8; c-> 8 9
  77. d=9; d-> 9 7
  78. a=b;
  79. b=c;
  80. c=d;
  81. d=a;
  82.  
  83. a=5; a-> 5 4
  84. b=-4; b-> -4 9
  85. c=9; c-> 9 +9 -9 -9=-9;
  86. a=-b;
  87. b=c;
  88. -c=-b;
  89. -a=-b; -4=-9 -5=x-y
  90. In L-value, Any variable with (-) changes into a expression . Expression gives a constant
  91.  
  92. Priority
  93.  
  94. a=2+3; 5
  95. +
  96. =
  97.  
  98. a=2+3+5; 10 If Priorities same, (+) it starts from Left to right
  99. a=5+5;
  100.  
  101. a=7-5+2; ->2+2;-> 4;
  102. a=5+2-7; ->7-7; 0;
  103. + -
  104. =
  105.  
  106. a=2+3*5; 1.* 2.+ 3.=
  107. a=2+15; 17
  108. a=2*3+3*4;
  109. a=6+3*4;
  110. a=6+12;
  111. a=18;
  112.  
  113. a=(2+3)*5;
  114. a=5*5;
  115. a=5*(3-1)+(3-1); 5*2+2; 10+2; 12;
  116. First Priority goes to the operator inside the ().
  117. () Changes the default priority.
  118.  
  119. a=3*10/2; * / (same priority) Left to Right
  120. a=10/5/2;
  121.  
  122.  
  123. Maths C Lang
  124. + Add Sum + Sum
  125. - Sub Dif -
  126. X Mul product *
  127. / Div Quotient /
  128. Remainder %
  129.  
  130. (/) Quotient - Result
  131. int/int => int
  132. int/float => float
  133. float/float => float
  134. float/int => float
  135.  
  136. a=5/2; 2
  137. a=-5/2; -2
  138. a= 5/-2; -2
  139. a=-5/-2; 2
  140. a= 5.0/2; 2.5
  141. a=5/2.0; 2.5
  142. a=5.0/2.0; 2.5
  143. a=2/5; 0
  144. a= 2/5.0; 0.4
  145. a=2.0/5; 0.4
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement