Multiple two 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.

Addition of two Array:
Example-
Array1 is {1,2,3,4,5}
Array2 is {1,0,1,1,0}
//Multiplication is {1,0,3,4,0}

program:

#include < iostream>
using namespace std;
class r4r
{
public:
int product(int *arr1,int *arr2)
{
int i;
cout<<"Multiplication of array is:"<< endl;
for(i=0;i< 5;i++)
{
cout<< arr1[i]*arr2[i]<<" ";
}
}
};
int main()
{
int a[5],b[5],i;
r4r obj;
cout<<"Enter 5 number in array1"<< endl;
for(i=0;i< 5;i++)
cin>>a[i];
cout<<"Enter 5 number in array2"<< endl;
for(i=0;i< 5;i++)
cin>>b[i];
obj.product(a,b);
return 0;
}


output-

Enter 5 number in array1
1 2 3 4 5
Enter5 number in array2
1 1 1 1 1
Multiplication of array is:
1 2 3 4 5

-In this program, we take a input of two Array.
-then we traverse both array and print the multiplication of each value.




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!