# Write A Program To Find Number Is Armstrong Or Not In C#?

The other answer is perfectly correct, but will not compile with g++ - this is a modified version that will:

#include <iostream>
#include <math.h>
using namespace std;

int main ()
{
int a,b=0,sum=0;
long int n, store;

cout <<"Enter the Number. : ";
cin >> n;
store = n;

for(;n>0;)
//counts the digits
{
a=n%10;
n=n/10;
b++;
}
for(;n>0;)
{
a=n%10;
sum=sum+pow(a,b);
n=n/10;
}
if(sum==n)
{
cout << store << " is an Armstrong number" << endl;
return 0;
}
else
{
cout << store << " is not an Armstrong number << endl;
return 0;
}
}
thanked the writer.
# include <iostream.h>
# include <conio.h>
# include <math.h>
void main ()
{ clrscr();
int a,b=0,sum=0;
long int n;
cout<<"ENter the NO. : ";
cin>>n;
for(;n>0;)
//counts the digits
{ a=n%10;
n=n/10;
b++;
}
for(;n>0;)
{ a=n%10;
sum=sum+pow(a,b);
n=n/10;
}
if(sum==n)
{ cout<<"IT IS AN ARMSTRONG NUMBER...";
getch();
}
else
{ cout<<"IT IS NOT AN ARMSTRONG NUMBER...";
getch();
}
}
thanked the writer.
Learn C# then coding will b easier
thanked the writer.
1. Program to Reverse a num

Ans:

#include stdio.h
#include conio.h
void main()
{
clrscr();
int r=0,d,m,n;
printf("Enter a value:");
scanf("%d", &n);
m=n;
do
{
d=m%10;
m= m/10;
r=r*10+d;
}
while(m!=0);

printf("%d is the reverse",r);
}
getch();
}

2. This program prints the Fibonacci series

#include
#include
void main(void)
{
int I,j,k,n;
clrscr();
I=0;
j=1;
printf("%d %d ",I,j);
for(n=0;n
thanked the writer.