Thursday, 26 January 2017

Random Number with Class Tutorial In DEV C++|| Illustration||Example||

#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
class housing
{
int regno;
char name[30];
char type[20];
long cost;
public:
void enter();
void disp();
void drawno();
}h[10];

void housing::enter()
{

cout<<"\nEnter Name:";
fflush(stdin);
gets(name);
cout<<"Enter House Type:";
fflush(stdin);
gets(type);
cout<<"Cost Of House:";
fflush(stdin);
cin>>cost;

regno=rand()%100+1;
system("cls");
cout<<"You ARE SuccessfuLLy Registered\n    Registration NO: "<<regno<<"\n Press any key to Continue......\n";
getch();
}
void housing::disp()
{
cout<<"Registration NO:"<<regno;
cout<<"\nName :"<<name;
cout<<"\nHouse Type:"<<type;
cout<<"\nCost: Rs "<<cost;
}
void drawno()
{
cout<<"Hello";
}
main()
{

int n,i=0;
cout<<"Enter No Of Recoreds You Want To ADD:";
cin>>n;
for(i=0;i<n;i++)
{
system("cls");
cout<<"Enter Details For: "<<i+1;
cout<<"\n=================\n==================\n";
h[i].enter();


}
system("cls");
cout<<"       Details Of Owner Are\n";
cout<<"   =============================\n";
for(i=0;i<n;i++)
{

cout<<"\n=================\n==================\n";
h[i].disp();


}
}

No comments:

Post a Comment

Amazon1Ads