/** 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();} }
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"); } }
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); } }