How to validate aadhaar card number in C++

In this tutorial, we will learn how to validate aadhaar card number in C++. Before directly moving to the topic i.e., how to validate aadhaar card number in C++. First, let us understand what is an aadhaar card number.

The aadhaar card number is a twelve(12) digit unique number. It has been governing by the Indian government. Therefore, this number is unique for every citizen of India.

Now, let us understand how to validate the aadhaar number. The aadhaar card number length is 12 digits. The aadhaar number is unique and does not start with 0 or 1. We validate through visiting the UIDIA website. Then entering the aadhaar card number. Then enter the OTP which is sent to the registered mobile number. By entering that OTP will validate the aadhaar card number. If it is the same as saved in the government database.

Let’s understand it with a program.

```//illustrating how to validate
#include<iostream>
using namespace std;

int main()
{
string s;
int c;

cin>>s;
//checking is it 12digit or not
if(s.length()!=12)
{
exit(0);
}

else
{
if(s[0]=='0' || s[0]=='1')
{
exit(0);
}

else
{
for(int i=0;i<12;i++)
{
if(isdigit(s[i])) // checks if value is number or not
{
c=c+1;
}
}
}

}

if(c==12)

else

return 0;
}```

The above only check 2 things first whether aadhaar number is of 12 digits. Second, it should not start with 0 or 1. The above code displays the output as given below:

```1. enter your aadhaar card number: 249844450851