TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rushal Arora
NA
112
175.6k
program for armstrong series
Dec 11 2013 1:28 PM
Write a program for armstrong series? I have tried in c++ but i want in C#.
#include "iostream"
#include "math.h"
using namespace std;
int main()
{
/*armstrong number -> if sum of cubes of indiviual digits is equal to the number itself
eq- if number is 371 => 3*3*3 + 7*7*7 + 1*1*1 = 371 (armstrong number)
*/
int num,cube=0,temp=0;
double remainder=0;
cout<<"enter the number";
cin>>num;
temp=num;
while(temp !=0)
{
remainder = temp % 10;
cout<<"remainder"<<remainder<<endl;
cube+=pow(remainder,3);
cout<<"cube"<<cube<<endl;
temp=temp/10;
cout<<"temp"<<temp<<endl;
}
if(cube==num)
{
cout<<"Number is armstrong";
}
else
cout<<"not";
return 0;
}
Reply
Answers (
1
)
how to get only the first tag contents in asp.net c
Conversion from C++ to C#