+ 2
Im stuck here can anyone help đđ function is a perfect square, which a given integer n, returns 1 if n is a perfect square.
#include<iostream> using namespace std; main() { float n,flag=0,m,l; //Flag is a predefined bit sequence that holds a binary value cout<<"ENTER THE NUMBER"<<endl; cin>>n; float i=0; do { i=i+10; m=i*i; }while(n>m); if(flag==1) cout<<"THE NUMBER IS A PERFECT SQUARE"<<endl; else cout<<"THE NUMBER ISN'T A PERFECT SQUARE"<<endl; }
2 RĂ©ponses
+ 6
#include <iostream>
using namespace std;
int main()
{
int n,i=1,sum=0;
cin >> n;
while(i<n)
{
if(n%i==0)
sum=sum+i;
i++;
}
if(sum==n)
cout << i << " is a perfect number\n"; else
cout << i << " is not a perfect number\n";
return 0;
}
+ 1
Thank you Mehak Jain for helping my assignment in c++ this is kent from philippines đ