# Find all Pairs of Numbers Whose Sum is Equal to a Given Number in C++ Full Project For Beginners

Welcome folks today in this blog post we will be `finding all pairs of numbers whose sum is equal to a given number in c++` All the full source code of the application is shown below.

In order to get started you need to make a `app.cpp` file and copy paste the following code

`app.cpp`

``````/* C++ program to find the pairs of number present in array whose sum is equal to a given number**
***give different sizes for array & the their values to get different result***
** enter a valid number sum otherwise noting will print on screen **
*/
#include <iostream>

using namespace std;
int main()
{
int size, num;
cout<<"Enter the size of array: ";
cin>>size;
int array[size];                            // array declaration

cout<<"Enter array elements: ";
for(int i=0;i<size;i++)
cin>>array[i];                          // input array values

cout<<"Enter the number whose pairs are to be found: ";
cin>>num;

for(int i=0;i<size-1;i++){                  // nested for loop
for(int j=i+1;j<size;j++){
if(array[i]+array[j]==num)
cout<<array[i]<<" and "<<array[j]<<endl;       // print pairs
}
}

return 0;
}``````

None Found