Armstrong Number Programs in Java using recursion | ISC Computer Science Class 11 & 12

preview_player
Показать описание
Design a class ArmNum to check if a given number is an Armstrong number or not. A number is said to be Armstrong if the sum of its digits raised to the power of length of the number is equal to the number.

Example:
371 = 33 + 73 + 13
1634 = 14 + 64 + 34 + 44
54748 = 55 + 45 + 75 + 45 + 85
Thus, 371, 1634 and 54748 are all examples of Armstrong numbers.

Some of the members of the class are given below:

Class name: ArmNum
Data members/instance variables:
n: to store the number.
l: to store the length of the number.
Methods/Member Functions:
ArmNum(int num): parameterized constructor to initialize the data member n = num.
int sumPow(int i): returns the sum of each digit raised to the power of the length of the number using recursive technique. E.g. 34 will return 32 + 42 (as the length of the number is 2)
void isArmstrong(): checks whether the given number is an Armstrong number by invoking the function sumPow() and displays the result with an appropriate message.

Specify the class ArmNum giving details of the constructor, int sumPow(int) and void isArmstrong(). Define a main() function to create an object and call the functions accordingly to enable the task.

You can follow/contact us here,

#AmplifyLearning #Computer
Рекомендации по теме
Комментарии
Автор

Sir I am watching all ur video and they are great.I request u sir pls put more prgms on recrusive and array

satadrumondal
Автор

sir aapse pdhke sb smjh aa ajata h ... Thanks a

UnknownUnknown-xmdf
Автор

Sir love u sir, your simplicity is next level ... tomorrow is my exam and i am sharing your video continuously to all of my friend who were calling me to help them
Sir once i again i waana confess that you are teaching very good

sanskargupta
Автор

were you really aiming for 50 likes sir😅.... well now it's 752👏🏻😂

trapbias
Автор

Thank you sir ...My all doubts are clear ...Thank you very much ...

mohabbat-e-deen
Автор

Can you post more videos on recursion?

deekshashaw
Автор

Write a Method to calculate and return the sum of the square of the digits of a number
‘n’ using recursive technique.
The method declaration is as follows:
int sumSq( int n )


Sir ye kaise hoga?

Onepiecetardd
Автор

Sir plzz make video for more recursion for ISC 2020 COMPUTER

yourbro
Автор

🙏🙏Sir I have a query
If we write return a+b then is the value of (a) returned or the entire (a+b) is returned?

bornforspeed
Автор

Sir class 10th k sbi programs icse k link dena pls only apki video

Jrtukuma_shorts
Автор

Sir, can u please make a video on types of recursion and their differences with examples

anushkaghosh
Автор

I used function argument...so wat should I type while executing....

hajashereefhajashereef
Автор

Sir samagh nhi aaya😢😢😢other method please❤

yusra
Автор

Sir Apne math function me (i, 1) kyu Lia jabki digits ka cube krna tha . To apko (i, 3) Lena chahiye tha

saraswatishukla
Автор

Sir ye 2019 me aya tha to 2020 me to nhi aayega na?

mohdyahya
Автор

Wo saare program jo 2019 me aa gaye wo nhi aayenge 2020 me

mohdyahya
Автор

Sir mera baar baar errors show krta hai sahi type krta hu to bhi

shubhamdey
Автор

T.m.r.m my computer exam 😢

sinan_egemen
Автор

Armstrong toh class 10th mai bhi karte hai

archismanbasu
visit shbcf.ru