Posts

Showing posts with the label Let us C

Let us C book Chapter 2 Exercise SOlutions

 [A] Point out the errors, if any, in the following C statements: (a) x = ( y + 3 ) ;   Proper  (b) cir = 2 * 3.141593 * r ; r is undefined  char = '3'; WHere is the name dude , no variable name given  (d) 4 / 3 * 3.14 * r * r * r = vol_of_sphere ; Right to left associativitiy applies and left side of = should contain only one variable  (e) volume = a 3 ; Error no exponentiation form avaiable  (f) area = 1 / 2 * base * height ; Correct  (g) si = p * r * n / 100 ; perfect  (h) area of circle = 3.14 * r * r ; space not allowed in variable name  peri_of_tri = a + b + c ; ok  slope = ( y2 – y1 ) ÷ ( x2 – x1 ) ; ok (k) 3 = b = 4 = a ; NOt ok - > left side of = cannot have constant  count = count + 1 ; perfect  (m) char ch = '25 Apr 12' ; not ok only one character allowed in single quote [B] Evaluate the following expressions and show their hierarchy. (a) ans = 5 * b * b * x - 3 * a * y * y - 8 * b * b * x + 10 * a * y ;...

Let us C book Chapter 1 Exercise Solutions

  [A] Which of the following are invalid C constants and why? ‘3.15’ : Valid C Constant falls into Real Constant category 35,550 : Invalid C Constant because comma is not allowed  3.25e2 : Valid Exponential format of Real Constant  2e-3 : Valid Exponential form of Real Constant  ‘eLearning’ : Invalid C Constant Because Only ONe character should be there and single quote present  “Show” : Valid C Constant  ‘Quest’ : Invalid C Constant because single quote present instead of double  2^3 : Invalid C Constant  4 6 5 2 : Invalid C Constant because spaces not allowed  [B] Which of the following are invalid variable names and why? B’day : Invalid Variable Name because single quote present  Int : Invalid Variable name because it is a reserved Keyword  $hello : Invalid C Variable Name  #Hash : Invalid because only alphabets, digits and underscores allowed in naming variable  Dot.  : Invalid  Number : Valid  totalArea...