Multiply two Array In Data structure 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.

Multiplication 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 < stdio.h>
int main()
{
int a[5],b[5],c[5],i;
printf("Enter 5 number in first array\n");
for(i=0;i< 5;i++)
scanf("%d",&a[i]);
printf("Enter 5 number in second array\n");
for(i=0;i< 5;i++)
scanf("%d",&b[i]);
// Now Multiple
for(i=0;i< 5;i++)
{
c[i]=a[i]*b[i];
}
//Now traverse
printf("After Multiplication\n");
for(i=0;i< 5;i++)
printf("%d,",c[i]);
}


output-

Enter 5 number in first array
1 1 2 3 1
Enter 5 number in second array
5 6 7 8 9
After Multiplication
5,6,14,24,9,

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




Leave a Comment:
Search
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!