Program to Display ‘1D’ numbers in Array by using Class in C++.

In this program we learn to Display input(numbers) provided by user by using class in Array.

 

 

Let’s write a program which Display 1D numbers in Array by using Class in C++.

 

 

Step 1: Let’s open turboC++ and write the following code .

 

 

// Code

 

// Add preprocessor

 

#include<conio.h>

#include<iostream.h>

class number

{

private :

int i,a[10];

public:

void input();

void display();

};

void number :: input()

{

cout<<”enter all numbers:”;

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

{

cin>>a[i];

}

}

void number :: display()

{

cout <<”numbers are:”;

{

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

{

cout<<”\n”<<a[i];

}

}

void main()

{

number n;

n.input();

n.display();

getch();

}

 

 

Step 2: Run the program and see output.

 

 

Output:

 

output

 

Happy Coding.

 

 

 

 

Tags: , ,