Signed and unsigned integer in C++ language by R4R Team

Basically, in numbers data_type like integer we have some range of 'int' in both side of 0, i.e., negative as well as positive.
we store negative as well as positive value in integer type variable.

signed variable:
In signed data_type we also have capability to store negative values.
-By default when we declared any data_type then it is signed

unsigned variable:
In unsigned variable data_type we only store positive values(including 0).
-Or when we want to store only positive value in that case we use unsigned integer.

unsigned int age;
-Because age can't be negative.

unsigned data_type variable_name;


#include < iostream>
using namespace std;
int main()
unsigned int age;
cout<<"Enter agen";
cout<<"Age is: "<< age;
return 0;


Enter age
Age is: 23

-In this program, if we enter some negative value then it will give an error.

Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!