You are on page 1of 1

LAB TEST 2

Name: Hafiz Muhammad Anas


CMS ID: 244774
Synd: C
OUTPUT
#include<iostream>
using namespace std;
void start(int&, int&);
void perfect(int, int);
int main()
{
int a = 0, b = 0;
start(a, b);
cout << "perfect numbers between the range are :" << endl;
if (a > 0 && b > 0)
perfect(a, b);
system("pause");
}
void start(int & a, int & b)
{
cout << "Enter your starting number " << endl;
cin >> a;
cout << "Enter your last number" << endl;
cin >> b;
}
void perfect(int a, int b)
{
int c, d, e;
for (int i = a; i <= b; i++)
{
e = 0;
c = i;
for (int j = 1; j < c; j++)
{
if (c % j == 0)
e = e + j;
}
if (e == c)
{
cout << e << endl;
}
}

You might also like