Let P = {2,3,4,5,6}, Q = {1, 3, 5, g} and R = {1, 2, 4, h}Find P – Q, Q – P and P Δ
//Let P = {2,3,4,5,6}, Q = {1, 3, 5, g} and R = {1, 2, 4, h}Find P – Q, Q – P and P Δ
#include <iostream>
#include <array>;
using namespace std;
int main()
{
int i,d,g,h;
int P [5] = {2,3,4,5,6}; //initializing first array
int Q [4] = {1, 3, 5,g}; //initializing second array
int R [4] = {1, 2, 4, h}; //initializing third array
for (i= 0; i<5; i++)
{
P[i]-=Q[i]; // aggregate the difference between the array of p and q
Q[i]-=P[i];
R[i]-=P[i];
}
//print the results
std::cout<<"The Value of P minus Q is ";
for(i=0; i<5; i++) std::cout<<P[i]<<" ";
std::cout<<std::endl;
std::cout<<"The value Q minus P is ";
for(i=0; i<5; i++) std::cout<<Q[i]<<" ";
std::cout<<std::endl;
std::cout<<"The value Q minus P is ";
for(i=0; i<5; i++) std::cout<<R[i]<<" ";
std::cout<<std::endl;
d= R[i]+Q[i];
cout<<"The change of P Δ is "<<d<<endl;
return 0;
}
Comments
Leave a comment