Write
a
program
in C++ to
display all ‘N’
arithmetic means between the consecutive elements of the
sum of Concatenated and Multiplexed versions of A1[R]
and A
2[R] entered by
a
user.
using namespace std;
#include <omp.h>
#include <stdio.h>
/*
Write a program in C++ to display all ‘N’ arithmetic means between the consecutive elements of the
sum of Concatenated and Multiplexed versions of A1[R] and A 2[R] entered by a user.
*/
#define R 5
main(void)
{
// int A1[R], A2[R];
float A1[R] = {2, 4, 7, 9, 10};
float A2[R] = {3, 8, 11, 10, 11};
int n,m;
float a,b,AM;
cout<<"\nA1["<<R<<"] = "; for(m=0;m<R-1;m++) cout<<A1[m]<<", "; cout<<A1[R-1];
cout<<"\nA2["<<R<<"] = "; for(m=0;m<R-1;m++) cout<<A2[m]<<", "; cout<<A2[R-1];
cout<<"\n\nConcatenated Array: ";
for(m=0;m<R;m++) cout<<A1[m]<<", ";
for(m=0;m<R-1;m++) cout<<A2[m]<<", ";
cout<<A2[R-1];
cout<<"\n\nContinuous elements:";
for(m=0;m<R;m++)
{
a = A1[m];
for(n=0;n<R;n++)
{
if(a+1 == A2[n])
{
AM = (a + A2[n])/2;
cout<<"\nA1["<<m<<"] = "<<A1[m]<<"\tA2["<<n<<"] = "<<A2[n]<<"\tArithmatic Mean = "<<AM;
}
}
}
}
Comments
Leave a comment