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 in C

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:

TypeSize (bytes)Format Specifier
int4 bytes%d
unsigned int4 bytes%u
short int2 bytes%hd
unsigned short int2 bytes%hu
long int4 bytes%ld
unsigned long int4 bytes%lu
long long int8 bytes%lld
unsigned long long int8 bytes%llu

Program to print Integer Data Types

Example 1:

Run
#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:

Run
#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

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription