Write a program using class which reads a list of N number of integer type in an array. It modifies the list by multiplying 10 to every number of the list. The modified list is displayed.
#include<iostream.h>
#include<conio.h>
class array
{
public: void readarray();
void multiply();
};
void array::readarray()
{
int a[10];
cout<<"Enter the elements of the Array"<<endl;
for(int i=0;i<=9;i++)
cin>>a[i];
}
void array::multiply()
{
int i,j,a[10],temp[10];
for(i=0;i<=9;i++)
{
for(j=0;j<=9;j++)
temp[i]=(a[i]*10);
}
cout<<"Result are as follows"<<endl;
for(j=0;j<=9;j++)
cout<<temp[j]<<endl;
}
void main()
{
array mul;
clrscr();
mul.readarray();
mul.multiply();
getch();
} |
#include<iostream.h>
#include<conio.h>
class array
{
public: void readarray();
void multiply();
};
void array::readarray()
{
int a[10];
cout<<"Enter the elements of the Array"<<endl;
for(int i=0;i<=9;i++)
cin>>a[i];
}
void array::multiply()
{
int i,j,a[10],temp[10];
for(i=0;i<=9;i++)
{
for(j=0;j<=9;j++)
temp[i]=(a[i]*10);
}
cout<<"Result are as follows"<<endl;
for(j=0;j<=9;j++)
cout<<temp[j]<<endl;
}
void main()
{
array mul;
clrscr();
mul.readarray();
mul.multiply();
getch();
}
Editorial Team
We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.