Skip to main content

Posts

Showing posts with the label CS

Integer arithmetic operations in C Language

  In the C programming language, integer arithmetic operations are performed using basic arithmetic operators. Here's a quick overview: /* Integer arithmetic operations*/ #include<stdio.h> int main(void) { int a=17,b=4; printf("Sum=%d\n",a+b); printf("Difference=%d\n",a-b); printf("Product=%d\n",a*b); printf("Quotient=%d\n",a/b); printf("Remainder=%d\n",a%b); return 0; } The given C code performs basic integer arithmetic operations on the variables a and b . Here's the expected output: Sum=21 Difference=13 Product=68 Quotient=4 Remainder=1 Explanation: Sum: 17 + 4 = 21 17 + 4 = 21 Difference: 17 − 4 = 13 17 − 4 = 13 Product: 17 × 4 = 68 17 × 4 = 68 Quotient: 17 / 4 = 4 17/4 = 4 (integer division, so the fractional part is truncated) Remainder: 17 % 4 = 1 17%4 = 1 (remainder when 17 is divided by 4)