CS13002 Programming and Data Structures | Section: 4/D, Spring 2005 |
Warm-up exercise
Write a C program that does the following:
- Declares two integer variables m and n.
- Reads the integers m and n from the user.
- Prints the following information:
- The sum m+n
- The difference m-n
- The product m*n
- The integer quotient m/n
- The integer remainder m%n
- The floating point quotient m/n
- The quantity m2+n2
- The quantity (m+n)2
Prepare your output on the following six pairs of values of (m,n):
- m = 100, n = 10.
- m = 10, n = 100.
- m = 561, n = -165.
- m = -561, n = 165.
- m = -561, n = -165.
- m = 1729721, n = 561165.
A sample run of your program is given below:
Enter m : 53 Enter n : 17 m + n = 70 m - n = 36 m * n = 901 m / n = 3 (integer division) m % n = 2 (integer division) m / n = 3.117647 (real division) m^2 + n^2 = 3098 (m + n)^2 = 4900