Program code: #include<iostream> using namespace std; int main() { //variable declaration int x, y; //variable declaration and initialization int sum=0;…