C programming Important airthmetic opearation questions.

-->
1.     Suppose a, b and c are integer variables that have been assigned the values a=8, b=3, and c=-5. Determine the values of each of the following arithmetic expressions.
(a) a + b + c (f) a % c
(b) 2 * b + 3 * (a – c) (g) a * b / c
(c) a / b (h) a * (b / c)
(d) a % b (i) (a * c) % b
(e) a / c (j) a * (c % b)
2.     Suppose x, y and z are floating-point variables that have been assigned the values x=8.8, y=3.5 and z=-5.2. Determine the values of each following arithmetic expressions.
(a) x + y + z (e) x / (y + z)
(b) 2 * y + 3 * (x – z) (f) (x / y) + z
(c) x / y (g) 2 * x / 3 * y
(d) x % y (h) 2 * x / ( 3 * y)
3.     Suppose c1, c2 and c3 are character-type variables that have been assigned the characters E, 5 and ?, respectively. Determine the numerical value of the following expressions, based upon the ASCII character set.
(a) c1 (f) c1 % c3
(b) c1 –c2 + c3 (g) '2' + '2'
(c) c2 - 2 (h) (c1 / c2) * c3
(d) c2 – '2' (i) 3 * c2
(e) c3 + '#' (j) '3' * c2
4.     A C program contains the following declarations:
int i, j:
long ix;
short s;
float x;
double dx;
char c;
Determine the data type of each of the following expressions.
(a) i + c (f) s + j
(b) x + c (g) ix + j
(c) dx + x (h) s + c
(d)((int) dx) + ix (i) ix + c
(e) i + x
5.     A C program contains the following declarations and initial assignments:
int i = 8, j = 5;
float x = 0.005, y = -0.01;
char c = ‘c’, d = ‘d’;
Determine the value of each of the following expressions. Use the values initially assigned to the variables for each expression.
(a)3 * i – 2 * j) % (2 * d – c)
(b)++i
(c)i++
(d)i <= j
(e)j != 6
(f)!(i <= j)
(g)!(x > 0)
(h)(i > 0) !! (j < 5)
(i)(x > y) && (i > 0) && (j < 5)
6.     A C program contains the following declarations and initial assignments:
int i = 8, j = 5, k;
float x = 0.005, y = -0.01, z;
char a, b, c = 'c', d = 'd';
Determine the value of the following assignment expression. Use the value originally assigned to the variables for each expression.
(a)z = k = x
(b)x *= 2
(c)i % j
(d)k = (j == 5) ? i : j
(e)z = (y >= 0) ? y : 0
(f)i -= (j > 0) ? j : 0
7.     Each of the following expression involves the use of a library function. Identify the use of each expression.
(a)abs(i – 2 * j)
(b)isdigit(c)
(c)toupper(d)
(d)cell(x)
(e)log(x)
(f)sprt(x*x + y*y)
(g)toascii(10 * j)
(h)fmod(x, y)
(i)sin(x – y, 3.0)
(j)strlen("hello\0")
(k)strops("hello\0", 'e')

0 comments:

Feel free to contact the admin for any suggestions and help.