Computer Science, asked by lunakrystal, 1 year ago

Write a c++ program to check whether a number is mystical or not

Answers

Answered by nitish8089
0
#include <iostream>
using namespace std;

int main() {
int a;
int sum=0;
cin>>a;
int temp=a;
do{
int x=temp%10;
sum+=x;
temp/=10;
}while(temp>0);
while(sum>9){
temp=sum;
sum=0;
do{
int x=temp%10;
sum+=x;
temp/=10;
}while(temp>0);
}
if(sum==3){
cout<<"number is a mystic number";
}
else{
cout<<"number is not a mystic number";
}
return 0;
}

check this code..
Similar questions