Multiple number to array in C++ by R4R Team

Array:
Array is the collection of different values having same data type.
-We have a integer Array that having all integer values.
-Character array is known as String.

What we do here?
Example-
Array is {1,2,3,4,5}
multiple 2 in Array then {2,4,6,8,10}

program:

#include < iostream>
using namespace std;
class r4r
{
public:
//class method or function
int function(int *arr,int n)
{
int i;
cout<<"Array after number multiple is:"<< endl;
for(i=0;i< 5;i++)
{
cout<< arr[i]*n<<" ";
}
}
};
int main()
{
int a[5],i,n;
r4r obj;
cout<<"Enter 5 number in array"<< endl;
for(i=0;i< 5;i++){
cin>>a[i];
}
cout<<"Enter number to multiple in array"<< endl;
cin>>n;
//pass in function
obj.function(a,n);
return 0;
}


output-

Enter 5 number in array
1 2 3 4 5
Enter number to multiple in array
2
Array after number multiple is:
2 4 6 8 10




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!