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

Remember that the short int data type is useful when you need to save memory and the range of values is within its limitations. If you need a broader range or more precision, you may want to use a regular int or other data types like long int or long long int.

Example:

#include <stdio.h>

int main() {
    short int a = 10;
    short int b = 20;

    if (a == b) {
        printf("a and b are equal.\n");
    } else if (a < b) {
        printf("a is less than b.\n");
    } else {
        printf("a is greater than b.\n");
    }

    return 0;
}

Explanation: 

In this example, we compare two short int values a and b. The program checks whether a is equal to b, less than b, or greater than b, and prints the corresponding message.
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
  Type casting with short int in C Qomplainerz 0 359 07-26-2023, 03:50 PM
Last Post: Qomplainerz
  User input and short int conversion in C Qomplainerz 0 391 07-26-2023, 03:49 PM
Last Post: Qomplainerz
  Overflow and underflow with short int in C Qomplainerz 0 380 07-26-2023, 03:48 PM
Last Post: Qomplainerz
  Arithmetic operations with short int in C Qomplainerz 0 404 07-26-2023, 03:46 PM
Last Post: Qomplainerz
  Storing short integers in C Qomplainerz 0 392 07-26-2023, 03:45 PM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 2 Guest(s)