Computer Science, asked by prathyushagovindraj, 8 months ago

Write a program to accept a number and check whether it in a 'Spy Number of not. (A number i
spy if the sum of its digits equals the product of its digita)
SampleInput: 1124
Sum of the digits - 1+1+2+4+=8
Product of the digits - 1*1*2*4=8​

Answers

Answered by PhysicsForever
1

Answer:

#include<iostream.h>

#include<conio.h>

#define max 10

void main()

{

clrscr();

unsigned long int m,n;

int dn,sum=0,product=1;

cout<<"Enter the number :";

cin>>m;

cout<<endl;

n=m;

while(n!=0)

{

dn = n%10;

sum+=dn;

product*=dn;

n=n/10;

}

if(sum==product)

{

cout<<"The entered number is a spy number. Thank you !";

}

else

{

cout<<"The entered number is not a spy number.Thank you !";

}

getch();

}

This is the overall logic of the program that you can use, i prefer coding in C++ language

Hope this helps you ! ^_^

Similar questions