This document contains a tutorial on data types and operators in C programming with examples. It includes:
1) Examples calculating final values of variables using operators like assignment, arithmetic, increment/decrement.
2) Code snippets to find the output of programs using operators like arithmetic, logical, bitwise on variables of types int and float.
3) Examples evaluating expressions involving relational and logical operators and calculating the values of variables.
4) A deadline for submission is provided at the end.
This document contains a tutorial on data types and operators in C programming with examples. It includes:
1) Examples calculating final values of variables using operators like assignment, arithmetic, increment/decrement.
2) Code snippets to find the output of programs using operators like arithmetic, logical, bitwise on variables of types int and float.
3) Examples evaluating expressions involving relational and logical operators and calculating the values of variables.
4) A deadline for submission is provided at the end.
This document contains a tutorial on data types and operators in C programming with examples. It includes:
1) Examples calculating final values of variables using operators like assignment, arithmetic, increment/decrement.
2) Code snippets to find the output of programs using operators like arithmetic, logical, bitwise on variables of types int and float.
3) Examples evaluating expressions involving relational and logical operators and calculating the values of variables.
4) A deadline for submission is provided at the end.
This document contains a tutorial on data types and operators in C programming with examples. It includes:
1) Examples calculating final values of variables using operators like assignment, arithmetic, increment/decrement.
2) Code snippets to find the output of programs using operators like arithmetic, logical, bitwise on variables of types int and float.
3) Examples evaluating expressions involving relational and logical operators and calculating the values of variables.
4) A deadline for submission is provided at the end.
Santa B. Basnet Tutorial -1: Data Type and Operators Santa B. Basnet
Data Type and Operators (b) int main (){
int x = 16, y = 18, z, w, p = 10, q; 1. Write the final value of the variables in the following expressions. y = x++; z = ++x; w = p--; q = ++p; (a) int i = 6, j = 5, k = 4; x = x + y + z; i = (i + k) / 3 + k % j + i * j * k / 20; // i = ? printf(“\n%d\t%d\t%d”, p, q, w); printf(“\n%d\t%d\t%d”, x, y, z); (b) int i = 4, j = 6, k = 7; return(0); k += (5 + i * j % 7) * 6 / (i + j) + 3; // k = ? } (c) int x = 10, y = 5, z, w = 9, p, q, r; 3. Find the output of the following programs: x += 10; y = x++; (a) int main (){ z = --x; w /= x; int a = 9; p = x + y; q = p + w; float b = 4 – 6; r = w << y; printf(“size of a is %d”, sizeof(a)); z = p++; //x = ?, y = ?, z = ?, p = ?, q = ? & r=? printf(“size of a + b is %d.”, sizeof(a+b)); return(0); (d) int k = 10, p = 6, m, n, q; } m = k + p % 2 + 9 * 4 / 2; (b) int main (){ n = m++ - k / 2; int x = 10, y = 5, a = 6, b = 27, c, d; q = ++n - (--m + p); // m = ?, n = ? and p = ? c = a & b; (e) int k = 5, i = 3, j = 25, m; c += x-- + y++ % ++a * a++; m = ++i * 100 + j * 10; b /= a + x + y; k = m / 100 + ++k; b /= a + x + y; d = b | c; k = m / (k++ * 5); // k = ? printf(“%d, %d ,%d ,%d, %d, %d”,x,y,a,b,c,d); 2. Find the output of: (Necessary headers are included) return(0); (a) int main () { } int a = 9, b = 15, c = 3, x, y, z; 4. If a = 10, b = 20, c = 5 & d = 15 then what does the x = a – b / 3 + c * 2 - 1; following expressions yield? y = a – b / (3 + c) * (2 - 1); a. x = (a==(c–2)&&c–(d+10)<25)||(c != b);// x = ? z = a - (b / (3 + c) * 2) - 1; b. y = (++a < ++b)? b – a : a – b;// y = ? printf(“\nx = %d,\ny = %d,\nz = %d”, x, y, z); return(0); } Submission deadline: mid-night of 29th of May, 22.
Everest Engineering College P a g e1|2 Everest Engineering College P a g e2|2