Write a program of array within class


 

/* Write a program of array within class*/

#include<iostream.h>

#include<conio.h>

class arr

{

public:

int i;

int a[5];

public:

void getdata();

void display();

};

void arr::getdata()

{

for(i=0;i<5;i++)

{

cout<<“enter value=”;

cin>>a[i];

}

}

void arr::display()

{

for(i=0;i<5;i++)

{

cout<<a[i];

}

}

void main()

{

clrscr();

arr a1;

a1.getdata();

a1.display();

getch();

}

/* output:

enter value=5

enter  value=9

enter value=8

enter  value=7

enter  value=6

59876*/

Related Posts

Comments are closed.