intnum,r,sum,temp,ul;Console.WriteLine("———————————————————————————————————————————");Console.WriteLine("Program to print the Armstrong numbers");Console.WriteLine("———————————————————————————————————————————");Console.Write("Enter the upper limit range ");ul=Convert.ToInt32(Console.ReadLine());Console.Write("\nArmstrong numbers are\n");for(num=1;num<=ul;num++){temp=num;sum=0;while(temp!=0){r=temp%10;temp=temp/10;sum=sum+(r*r*r);}if(sum==num){Console.WriteLine("{0} ",num);}}Console.WriteLine("———————————————————————————————————————————");
Output
kodingwindow@kw:~/csharp$ dotnet run
———————————————————————————————————————————
Program to print the Armstrong numbers
———————————————————————————————————————————
Enter the upper limit range 1000
Armstrong numbers are
1
153
370
371
407
———————————————————————————————————————————
kodingwindow@kw:~/csharp$
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?