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






/* 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: ";
    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: ";

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

    return 0;


Similar Posts:

    None Found

Leave a Reply

Your email address will not be published. Required fields are marked *