Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arithmetic operations with short int in C
#1
Example:

#include <stdio.h>

int main() {
    short int a = 1000;
    short int b = 200;

    // Addition
    short int sum = a + b;
    printf("Sum: %d\n", sum);

    // Subtraction
    short int difference = a - b;
    printf("Difference: %d\n", difference);

    // Multiplication
    short int product = a * b;
    printf("Product: %d\n", product);

    // Division
    short int quotient = a / b;
    printf("Quotient: %d\n", quotient);

    return 0;
}

Explanation:

Explanation: In this example, we perform basic arithmetic operations (addition, subtraction, multiplication, and division) using short int variables. The result of each operation is stored in a short int variable and then printed using the %d format specifier in printf.
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Basic arithmetic operations with the double datatype in C Qomplainerz 0 245 07-26-2023, 06:01 PM
Last Post: Qomplainerz
  Comparisons with short int in C Qomplainerz 0 261 07-26-2023, 03:51 PM
Last Post: Qomplainerz
  Type casting with short int in C Qomplainerz 0 236 07-26-2023, 03:50 PM
Last Post: Qomplainerz
  User input and short int conversion in C Qomplainerz 0 263 07-26-2023, 03:49 PM
Last Post: Qomplainerz
  Overflow and underflow with short int in C Qomplainerz 0 256 07-26-2023, 03:48 PM
Last Post: Qomplainerz
  Storing short integers in C Qomplainerz 0 258 07-26-2023, 03:45 PM
Last Post: Qomplainerz
  Pointer arithmetic in C Qomplainerz 0 169 07-25-2023, 11:41 AM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 1 Guest(s)