Storing short integers in C - Printable Version +- QP School (https://qomplainerzschool.lima-city.de) +-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3) +--- Forum: C 18 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=32) +--- Thread: Storing short integers in C (/showthread.php?tid=5146) |
Storing short integers in C - Qomplainerz - 07-26-2023 Description: In C, the short int data type is used to represent integer values with a smaller range than regular int. It is a signed integer type that typically occupies 2 bytes in memory, which means it has a smaller range of representable values compared to a regular int. Example: #include <stdio.h> int main() { // Declare and initialize a short int variable short int myShortInt = 32767; // Print the value of the short int variable printf("Value of myShortInt: %d\n", myShortInt); return 0; } Explanation: Explanation: In this example, we declare a short int variable called myShortInt and initialize it with the value 32767. The %d format specifier is used in printf to print the value of the short int variable. |