#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<stdio.h>
#include<fstream.h>
void numeric();
void foldadd();
void dividprime();
int l,sum=0,val=0;
char name[12];
int n[12];
class student
{
public:
char name[20];
int rollno,marks,attendence;
void getdata()
{
cout<<"enter student name:"<<endl;
gets(name);
cout<<"enter student rollno:"<<endl;
cin>>rollno;
cout<<"enter student marks:"<<endl;
cin>>marks;
cout<<"enter student attendence:"<<endl;
cin>>attendence;
}
void putdata()
{
cout<<name<<"\t"<<rollno<<"\t"<<marks<<"\t"<<attendence<<endl;
}
};
void main()
{
int n,ch;
clrscr();
student s;
fstream f,f1;
f.open("hash.addr",ios::out);
cout<<"enter how many records do u want:"<<endl;
cin>>n;
for(int i=0;i<n;i++)
{
s.getdata();
f.write((char *)&s,sizeof(s));
}
f.close();
cout<<"the records in the file are:"<<endl;
f1.open("hash.addr",ios::in);
f1.seekg(0,ios::beg);
while(f1.read((char *)&s,sizeof(s)))
{
s.putdata();
}
f1.close();
while(1)
{
cout<<"MENU"<<endl;
cout<<"1.NUMERIC"<<endl;
cout<<"2.FOLDADD"<<endl;
cout<<"3.ADDRESS"<<endl;
cout<<"4.EXIT"<<endl;
cout<<"enter ur choice:"<<endl;
cin>>ch;
switch(ch)
{
case 1:numeric();break;
case 2:foldadd();break;
case 3:dividprime();break;
case 4:exit(1);
default:cout<<"invalid choice"<<endl;
}
}
}
void numeric()
{
cout<<"enter string:"<<endl;
gets(name);
l=strlen(name);
for(int i=0;i<l;i++)
{
n[i]=toascii(name[i]);
}
for(i=l;i<12;i++)
{
n[i]=32;
}
for(i=0;i<12;i++)
{
cout<<n[i]<<"\t";
}
}
void foldadd()
{
for (int i=0;i<12;i+=2)
{
sum=100*n[i]+n[i+1];
cout<<sum<<"\t";
}
cout<<"\n";
for(i=0;i<12;i+=2)
val=(val+100*n[i]+n[i+1])%19937;
cout<<"THE REQUIREFD VALUE IS:";
cout<<val;
cout<<"\n";
}
void dividprime()
{
int p,a;
cout<<"enter the primme nearer to required adresses:"<<endl;
cin>>p;
a=val%p;
cout<<"the required home address is:"<<a<<endl;
}
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<stdio.h>
#include<fstream.h>
void numeric();
void foldadd();
void dividprime();
int l,sum=0,val=0;
char name[12];
int n[12];
class student
{
public:
char name[20];
int rollno,marks,attendence;
void getdata()
{
cout<<"enter student name:"<<endl;
gets(name);
cout<<"enter student rollno:"<<endl;
cin>>rollno;
cout<<"enter student marks:"<<endl;
cin>>marks;
cout<<"enter student attendence:"<<endl;
cin>>attendence;
}
void putdata()
{
cout<<name<<"\t"<<rollno<<"\t"<<marks<<"\t"<<attendence<<endl;
}
};
void main()
{
int n,ch;
clrscr();
student s;
fstream f,f1;
f.open("hash.addr",ios::out);
cout<<"enter how many records do u want:"<<endl;
cin>>n;
for(int i=0;i<n;i++)
{
s.getdata();
f.write((char *)&s,sizeof(s));
}
f.close();
cout<<"the records in the file are:"<<endl;
f1.open("hash.addr",ios::in);
f1.seekg(0,ios::beg);
while(f1.read((char *)&s,sizeof(s)))
{
s.putdata();
}
f1.close();
while(1)
{
cout<<"MENU"<<endl;
cout<<"1.NUMERIC"<<endl;
cout<<"2.FOLDADD"<<endl;
cout<<"3.ADDRESS"<<endl;
cout<<"4.EXIT"<<endl;
cout<<"enter ur choice:"<<endl;
cin>>ch;
switch(ch)
{
case 1:numeric();break;
case 2:foldadd();break;
case 3:dividprime();break;
case 4:exit(1);
default:cout<<"invalid choice"<<endl;
}
}
}
void numeric()
{
cout<<"enter string:"<<endl;
gets(name);
l=strlen(name);
for(int i=0;i<l;i++)
{
n[i]=toascii(name[i]);
}
for(i=l;i<12;i++)
{
n[i]=32;
}
for(i=0;i<12;i++)
{
cout<<n[i]<<"\t";
}
}
void foldadd()
{
for (int i=0;i<12;i+=2)
{
sum=100*n[i]+n[i+1];
cout<<sum<<"\t";
}
cout<<"\n";
for(i=0;i<12;i+=2)
val=(val+100*n[i]+n[i+1])%19937;
cout<<"THE REQUIREFD VALUE IS:";
cout<<val;
cout<<"\n";
}
void dividprime()
{
int p,a;
cout<<"enter the primme nearer to required adresses:"<<endl;
cin>>p;
a=val%p;
cout<<"the required home address is:"<<a<<endl;
}
No comments:
Post a Comment