Computer Science, asked by dhanamvijay2002, 11 months ago

PLEASE HELP ME FRIENDS...

Write a C++ program...

The "signature" of a function is the first line which gives the return type, the name of the function and the parameters with their types.  As an example the signature of the gcd function is


int gcd(int m, int n)



Write a function with the following signature


bool perfect(int n)


It should return true if the sum of the divisors of n smaller than n add to n.  Otherwise it should return false.  As an example, for n = 28, the function should return true, because the divisors are 1, 2, 4, 7, 14.  To find the sum of the divisors simply go over the numbers from 1 to n-1 and see if they divide n, if yes add that number to a running total that you maintain.


Input
28
Output
1

Input
6
Output
1

Input
9
Output
0

Input
23
Output
0

Answers

Answered by sindhusindhu33303
0

Answer:

it is divided by odd number

Answered by mariospartan
0

Explanation:

#include<bits/stdc++.h>  

using namespace std;  

bool perfect(int n)  

{  

// Final result of summation of divisors  

int result = 0;  

// find all divisors which divides 'num'  

for (int i=2; i<=sqrt(n); i++)  

{  

 // if 'i' is divisor of 'num'  

 if (n%i==0)  

 {  

  // if both divisors are same then add  

  // it only once else add both  

  if (i==(n/i))  

   result += i;  

  else

   result += (i + n/i);  

 }  

}  

 cout<<"result = " << result+1;

if((result) ==0)

           return false;

     else

           return true;

}  

int main()  

{  

int n = 28;  

if(perfect(n))  

     cout<<"\nThe given number has divisor";

   else

     cout<<"\nThe given number does not have a divisor";

return 0;  

}  

To Know More:

https://brainly.in/question/12306522

Write a C program to read and display different data type values. Sample Input and Output: Enter int, short int and long int values : 23456 212 43567184 Enter float, double and long double values : 3.21 4.5678 11.234567 Enter a character : A Given int value : 23456 Given short int value : 212 Given long int value : 43567184 Given float value : 3.210000 Given double value : 4.567800 Given long double value : 11.234567 Given character​

https://brainly.in/question/8526433

C program to generate numbers between 1 and 100 which are divisible by 2

Similar questions