Write a program to check SSN

// Header file #include<iostream> #include<math.h> using namespace std; int main() { //Declare arrays as double data type double a[20]; double b[20]; double SSN; cout<<"Enter social security number(SSN)"<<endl; for(int i=0;i<=5;i++) { //Assign enter SSN in array cin>>SSN; a[i]=SSN; } cout<<"The Input SSN numbers are:"<<endl; for(int i=0;i<=5;i++) { //Display input SSN cout<<a[i]<<endl; } //Determine modulus of input SSN cout<<"The modulus of input SSN number is:"<<endl; int i=0; for(int j=0;j<=5;j++) { b[j]=fmod(a[i],1021); i++; } for(int j=0;j<=5;j++) { cout<<b[j]<<endl; } for(int i=0;i<=5;i++) { for(int j=i+1;j<=5;j++) { //Compare old memory location with new memory location // check the memory location is assign or not if(b[i]==b[j]) { for(int k=0;k<=5;k++) { double c[20]; //display memory location that is matching cout<<"Here, Collision occure at:"; cout<<b[i]; //Detemine new memory location and assign them. b[k]=b[j]+fmod(b[i],1021); cout<<"New location for linking of the file will be:"<<endl; cout<<b[k]; cout<<endl; return b[i]; } } } } //Display statememt if not match with old memory location cout<<"collision not occur"; }

Post a Comment

Previous Post Next Post