Computer Science, asked by prathm2281, 11 months ago

Encrypt using Armstrong number
Nowadays, we use social media a lot. We usually send messages, pictures, etc to each other. So, encrypting and decrypting should be done properly to avoid hacking. Irin is developing a program for the same where color encrypting is done with the help of Armstrong numbers. Can you help Irin to write program to check whether a number is an Armstrong number or not.

#include
int power(int m,int n)
{
int j,i;
for(i=1,j=1;i<=n;i++)
j=j*m;
return j;
}
int arm(int n)
{
//Your code goes here
}
int main()
{
int n;
std::cin>>n;
if(arm(n)==1)
std::cout<<"Kindly proceed with encrypting";
else
std::cout<<"It is not an Armstrong number";

}




complete the following code

Answers

Answered by Yamini1999
2

Answer:

#include <iostream>

using namespace std;

int main()

{

int n,sum=0,temp,p;

cin>>n;

temp=n;

while(n>0)

{

p = n%10;

sum = sum + (p*p*p);

n = n/10;

}

if(temp == sum)

{

cout<<"Kindly proceed with encrypting\n";

}

else

{

cout<<"It is not an Armstrong Number\n";

}

return 0;

}

Similar questions