Professional Documents
Culture Documents
Programming Fundamental (SE-108) (Lab MID)
Programming Fundamental (SE-108) (Lab MID)
Arslan Haider
*------------------------*
b)
Ans:
Output:
1
*------------------------*
Q#2: Illustrate the outputs of following program? (5+5=10 mark, CLO 1)
a)
Ans:
Output:
a
0.333333
num2 is greater
1
*------------------------*
b)
Ans:
Output:
*******
******
*****
****
***
**
*
*------------------------*
Q3: Write C++ Program to find perfect numbers between 2 intervals.
Note: A positive integer that is equal to the sum of its proper divisors
is a perfect number. The smallest perfect number is 6, which is the sum
of 1, 2, and 3. (6 marks, CLO 1)
Ans:
Output:
C++ Codes:
#include <iostream>
using namespace std;
int main()
{
float first;
float second;
cout << "Enter the intervals : ";
cin >> first >> second;
cout<< endl;
cout << "Perfect numbers between " << first << " and " << second << " :
is ";
for (int i = first; i <= second; i++)
{
if (Perfect(i))
{
cout << i <<", ";
}
}
return 0;
}