- 0
Notifications Mark All Read
- Login
- Get Prime
Int Data Type in C
C-Int Data Type
On this page we will discuss about Int Data Type which is used in C. The Integer data type is used to store whole numbers which can be zero, positive, and negative values with no decimal.Int Data Type used in C
In C programming , the int data type can be both signed or unsigned. The unsigned int data type is used to store values in the range of zero to positive and signed int data type stores only negative values.If an integer variable is of unsigned type then it is assumed to be positive by default in C.
Declaration of Integer type variable
int variable;
The int data type in C can be further divided into short, int, and long data types.
The integer data types with their size and format specifier are given below in the table:
Type | Size (bytes) | Format Specifier |
---|---|---|
int | 4 bytes | %d |
unsigned int | 4 bytes | %u |
short int | 2 bytes | %hd |
unsigned short int | 2 bytes | %hu |
long int | 4 bytes | %ld |
unsigned long int | 4 bytes | %lu |
long long int | 8 bytes | %lld |
unsigned long long int | 8 bytes | %llu |
Program to print Integer Data Types
Example 1:
#include <stdio.h> int main() { // Integer value with positive data. int p = 13; // Integer value with negative data. int q = -13; // U or u is Used for Unsigned int in C. int r = 76U; // L or l is used for long int in C. long int s = 88889L; printf("The integer value with positive data is: %d\n", p); printf("The integer value with negative data is: %d\n", q); printf("The integer value with an unsigned int data is: %u\n", r); printf("The integer value with an long int data is: %ld", s); return 0; }
Output:
The integer value with positive data is: 13 The integer value with negative data is: -13 The integer value with an unsigned int data is: 76 The integer value with an long int data is: 88889
Example 2:
#include <stdio.h> int main() { // Integer variable of type short. short int x=10000; // Integer variable of type int. int y=15612234; // Integer variable of type long. long number1=566678893324; // Integer variable of type long long. long long number2=81454486154787474; // Displaying the output on the screen printf("x is %hd \n y is %d \n number1 is %ld \n number2 is %lld \n",x,y,number1,number2); return 0; }
Output:
x is 10000 y is 15612234 number1 is 566678893324 number2 is 81454486154787474
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment