#include <iostream> #include<iomanip> using namespace std; int main() { int rem,sum=0,num; cout<<"enter a number\n"; cin>>num; for(int i=num;i>0; i = i/10 ){ rem = i%10; sum = rem+sum; } if (num%sum==0){cout<<"harshad number"<<endl;} else cout<<"non harshad"<<endl; return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter