Sarath Kumar
Write a program to print Armstrong numbers between 1 to 1000
By Sarath Kumar in C# on Feb 25 2014
  • Avikshith Aradhya
    May, 2016 30

    /** C# Program to Print all the Armstrong Numbers from 1 to 1000*/ using System; class Program {static void Main(){int a, b, c, d;for (int i = 1; i <= 1000; i++){a = i / 100;b = (i - a * 100) / 10;c = (i - a * 100 - b * 10);d = a * a * a + b * b * b + c * c * c;if (i == d){System.Console.WriteLine("{0}", i);}} Console.Read();} }

    • 0
  • Munesh Sharma
    Apr, 2014 4

    int num,r ,save, newnum =0,count=0; console.writeline("enter a name"); num = console.readline(); save =num; while(num <= 1000) { while(num!=0) { num = num/10; count++; } num = save; whaile(num!=0) { r=num%10; newnum = newnum+p0w(r,count); num =num/10; } if(newnum ==save) console.writeline("number is nor armstrong{0}", save); else console.writeline("number is nor armstrong"); } }

    • 0
  • Sarath Kumar
    Feb, 2014 25

    int a, b, c, d;

                for (int i = 1; i <= 1000; i++)
                {
                    a = i / 100;
                    b = (i - a * 100) / 10;
                    c = (i - a * 100 - b * 10);
                    d = a * a * a + b * b * b + c * c * c;
                    if (i == d)
                    {
                        System.Console.WriteLine("{0}",i);
                    }
                }

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS