Computer Science, asked by nbhargavramnavuluri6, 8 months ago

code in c++
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.

Input (stdin)
1634

Output (stdout)
Kindly proceed with encrypting

Answers

Answered by jjzach21
4

Answer:

Armstrong number: A number that is equal to the sum of cubes of its digits.

Explanation:

#include<iostream>

#include <cmath>  

using namespace std;

int main()

{

int num;

int f,rem,sum=0,temp,a=0;

 

cin>>num;

temp=num;

while(temp != 0)

{

temp=temp/10;

a=a+1;

}

f=num;

while(f!=0)

{

rem=f%10;

sum = sum + pow(rem,a);

f=f/10;

}

if( sum == num )

cout<<"Kindly proceed with encrypting";

else

cout<<"It is not an Armstrong number";

}

int power(int c, int d)

{

   int pow=1;

   int i=1;

   while(i<=d)

   {

     pow=pow*c;

     i++;

    }

    return pow;

}

Similar questions