Let Us C
Chapter – 2: C Instructions, Section – A, Exercise-1
Point out the errors, if any, in the following C statments:
(a) x = (y + 3);
(b) cir = 2*3.141593*r;
(c) char = ‘3’;
(d) 4/3*3.14*r*r*r = vol_of_sphere
(e) volume = a3;
(f) area = 1/2*base*height;
(g) si = p*r*n/100;
(h) area of circle = 3.14*r*r;
(i) per_of_tri = a + b + c;
(j) slope = (y2 – y1)÷(x2 – x1);
(k) 3 = b = 4 = a;
(l) count = count + 1;
(m) char ch = ’25 Apr 12′;
Chapter – 2: C Instructions, Section – B, Exercise-1
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;
(b) res = 4*a*y/c-a*y/c;
(c) s = c + a*y*y/b;
(d) R = x*x + 2*x + 1/2*x*x + x + 1;
Chapter – 2: C Instructions, Section – C, Exercise-1
Fill the following table for the expressions given below and then evaluate the result.
(a) g = 10/5/2/1;
(b) b = 3/2 + 5*4 / 3
(c) a = b = c = 3 + 4;
(d) x = 2 – 3 + 5 * 2 / 8 % 3;
(e) z = 5 % 3 / 8 * 3 + 4;
(f) y = z = -3 % -8 / 2 + 7;
Chapter – 2: C Instructions, Section – D, Exercise-1
Convert the following equations into corresponding C statements
(a) z = ((x + 3) X^3) / ((y – 4)(y + 5))
(b) R = (2v + 6.22(c + d)) / (g + v)
(c) A = (7.7b (xy + a) / c – 0.8 + 2b) / ((x + a)(1 / y))
(d) X = (12x^3)/4x + (8x^2)/4x + (x/8x) + 8/8x;
Chapter – 2: C Instructions, Section – F, Exercise-1
State whether the following statements are True or False
(a) * or /, + or – represents the correct hierarchy of arithmetic operators in C.
(b) [ ] and { } can be used in Arithematics instructions.
(c) Hierarchy decides which operator is used first.
(d) In C, Arithematic instruction cannot contain constants left on side of =.
(e) In C ** operator is used for exponential operations
(f) % operator cannot be used on floats.
Chapter – 2: C Instructions, Section – G, Exercise-1
Fill in the blanks:
(a) In y = 10*x/2 + z; _____ operation will be perofrmed first.
(b) If a is an integer variable, a = 11/2; will store _____ in a.
(c) The expression, a = 22 / 7 * 5 / 3; would evaluate to _____.
(d) The expression, a = 5000*3+6754; would evaluate to ____.
(e) The expression x = -7 % 2 – 8; would evaluate to ____.
(f) If d is a float the operation d = 2 / 7.0 would store ____in d.
Chapter – 2: C Instructions, Section – F, Exercise-1
If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’)
Video Source