| Forum |
|
|||||||
| Programming The destination for developers - C, C++, Java, Python and the lot |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
| Advertisements. Register and be a member of the community to get rid of them. | |
|
Advertisement
|
|
|
|
#2 (permalink) |
|
>:)I-):(|)8-X
Join Date: Sep 2004
Location: ಬೆಂಗಳೂರು (Bengaluru)
Posts: 3,512
|
Is thats a assignment given by your school/college ?
__________________
i5 2400 | DH67BL | G.Skill Ripjaw 4 GB | FSP SAGA II 500W | CM 430 Black Elite | MSI R6850 Cyclone PE/OC | XBox 360 Controller | 21.5" Samsung Sync Master 2233 | 4 Mbps UL |
|
|
|
|
#3 (permalink) | |
|
C# Be Sharp !
Join Date: Jun 2006
Location: Toronto
Posts: 1,805
|
Quote:
Well here's the main logic: 1. extract each digit , be taking modulus from 10(i.e. num % 10) or string operators if you're usin java n treatin as string. 2. then square that digit 3. add all squares 4. check if result is same as original number 5. if yes then number is armstrong , else not Hope it helped
__________________
There are 10 types of people in the world: those who understand binary and those who do not. |
|
|
|
|
|
#5 (permalink) |
|
God of Mistakes...
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,905
|
and create a function which returns 1 if number is Armstrong & otherwise 0.
Use a for loop in main() to pass numbers one by one to that function & if it returns 1, then print that number as an Armstrong !!! got it ??
__________________
Registered Linux User #468778 ---------------------------------- http://twitter.com/_Garbage_ |
|
|
|
|
#6 (permalink) |
|
damn busy...
Join Date: Sep 2006
Location: Jhansi/Meerut
Posts: 1,973
|
i can make it using while loop as it is for a given limit of numbers.
its a school assignment .ICSE or ISC .right
__________________
MSI GX660 with ATI 5870 Dell Studio 15(1555) 1TB+1.5TB external|N86|ZTE Blade|5230|E63|EP-630|Soundmagic PL50|Sennheiser CXL 400|Meelec M11P+ www.techjunkiez.com |
|
|
|
|
#7 (permalink) |
|
Banned
Join Date: May 2004
Location: Baudland
Posts: 2,430
|
d00ds let d thread starter show us wat hes done and den v cud go abt correctin it instead of just tellin him how 2 do it [code/alg/flow]
let us not encourage members who want 2 use d forum to get his/her hw done by some 1 else |
|
|
|
|
#8 (permalink) |
|
die blizzard die! D3?
Join Date: Aug 2007
Location: Event horizon
Posts: 2,340
|
I think he is stuck somewhere.And dudes you know that programming skills increases most when you read and understands codes written by others.
I don't know c++(i have just started it) but I think following c code should work for you.Note that I haven't checked if its running or not but I think its ok(atleast the logic is ok). ok here it is: void main() { int n,i,p,r,sum=0; printf("Enter the no.:\n"); scanf("%d",&n); for(i=0;i<=n;i++) {r=i; while(r!=0) {p=r%10; r=r/10; sum=sum+p*p*p; } if(sum==i) printf("%d\t",sum); sum=0; } getch(); clrscr(); } CHECKED,IT'S WORKING
__________________
Stealing your women and horses since 1843. Last edited by The_Devil_Himself; 14-08-2007 at 11:36 PM. |
|
|
|
|
#9 (permalink) |
|
Broken In
Join Date: Apr 2005
Posts: 133
|
he wanted it in c++....these days they dont teach c before teaching c++...so I think u shud explain the printf scanf commands or use cin cout....coz i too dont know the printf scanf commands
__________________
Abhishek Bhattacharya |
|
|
|
|
#10 (permalink) |
|
God of Mistakes...
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,905
|
@ The_Devil_Himself
U should NOT told him the code. But u did !!! huh...
__________________
Registered Linux User #468778 ---------------------------------- http://twitter.com/_Garbage_ |
|
|
|
|
#12 (permalink) | |
|
die blizzard die! D3?
Join Date: Aug 2007
Location: Event horizon
Posts: 2,340
|
Quote:
__________________
Stealing your women and horses since 1843. |
|
|
|
|
|
#13 (permalink) | |
|
Pee into the Wind...
Join Date: May 2007
Location: Mumbai
Posts: 782
|
Quote:
Every single digit no. except zero is armstorng no.Hava look here. for more info.
__________________
Life is as complicated as you say it is. |
|
|
|
|
|
#14 (permalink) |
|
18 Till I Die............
Join Date: Jul 2004
Location: India, Mumbai, Marine Lines
Posts: 5,792
|
According to http://mathworld.wolfram.com/NarcissisticNumber.html , shady_inc is right.
|
|
|
|
|
#16 (permalink) | |
|
C# Be Sharp !
Join Date: Jun 2006
Location: Toronto
Posts: 1,805
|
Quote:
__________________
There are 10 types of people in the world: those who understand binary and those who do not. |
|
|
|
|
|
#17 (permalink) | |
|
>:)I-):(|)8-X
Join Date: Sep 2004
Location: ಬೆಂಗಳೂರು (Bengaluru)
Posts: 3,512
|
That guy "sai_cool" posted this question and never came back
Quote:
__________________
i5 2400 | DH67BL | G.Skill Ripjaw 4 GB | FSP SAGA II 500W | CM 430 Black Elite | MSI R6850 Cyclone PE/OC | XBox 360 Controller | 21.5" Samsung Sync Master 2233 | 4 Mbps UL |
|
|
|
|
|
#18 (permalink) |
|
God of Mistakes...
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,905
|
^^ U should say "Not logged in" bcoz he may be in Guests
__________________
Registered Linux User #468778 ---------------------------------- http://twitter.com/_Garbage_ |
|
|
|
|
#19 (permalink) | |
|
die blizzard die! D3?
Join Date: Aug 2007
Location: Event horizon
Posts: 2,340
|
Quote:
Anyways I prefer fibonacci series over armstrong series....lols
__________________
Stealing your women and horses since 1843. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| which program used | gramesh | QnA (read only) | 6 | 20-04-2007 09:29 PM |
| program? | rounit | Software Q&A | 6 | 10-04-2007 10:54 PM |
| program to run vb | shivi4 | QnA (read only) | 2 | 24-06-2005 10:43 AM |
| new program in 'close program menu' list and more....... | vishakadatta | QnA (read only) | 2 | 12-04-2005 11:33 PM |
| C++ Program Q. | shwetanshu | Programming | 5 | 09-02-2005 01:50 PM |