Check whether a number is armstrong by calculation order
Duration: 7 min
This video lesson is available to enrolled students.
Inside: a video lesson and guided study material.
Module outline
- TCS One Shot Free Videos & Notes: TCS Preparation
- Numerical Ability (Foundation Section): Ratio and Proportion (Ratios), Divisibility Rules, Data Interpretation, Mixture and Alligation, Permutation and Combination, Logarithm, Number System, HCF LCM, Sequence and Series (Series), Speed Time and Distance, Percentage, Average, Powers and Exponents (Surds and Indices), Algebra, Probability, Profit and Loss, Simple Interest and Compound Interest, Time and Work, Pipe and Cistern, Mensuration and Geometry, Mental Ability, Age Problems, Statistics, Arithmetic, Partnership, Speed Mathematics and Basic Mathematics
- Reasoning Ability (Foundation Section): Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Syllogisms, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Seating Arrangements, Blood Relations, Directions (Direction Test), Analytical Reasoning (Counting Figures Reasoning), Puzzle Solving (Puzzles), Calendar, Clock, Cubes & Dices, Selection Decision Table (Decision Making), Crypt Arithmetic, Venn Diagram, Data Arrangement, Inequality, Analogy, Ranking, Order and Sequence, Logical Sequence Of Words
- New Pattern-Verbal Ability (Foundation Section): Sentence Completion (Fill in the blanks), English Writing Ability
- Old Pattern-Verbal Ability (Foundation Section): Vocabulary, Noun, Subject Verb Agreement (Verb Noun Agreement), Adjectives, Tenses, Pronoun, Preposition, Articles, Direct and Indirect Speech, Conjunction, Modals, Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Sentence Correction (Error Correction), Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Verbal Analogy (Word Based Analogy), Active Passive Voice (Voice), Determiner, Facts, Inference and Judgements, Adverb, Cloze Test (Cloze Passage), Sentence Construction, Verb
- Advanced Quantitative Ability: TCS NQT Advanced Quantitative Ability
- Advanced Reasoning Ability: TCS NQT Advanced Reasoning Ability
- Advanced Coding: Coding Questions by Yash Sir, C Programming by Yash Sir, Python for Placements by Yash Sir, DSA using Python, Object Oriented Programming (OOPS), Programming in C++, Java
- TCS Full Length Mock Test:
- TCS Interview & Resume Prep: MR & HR Interview Preparation, TCS Interview Preparation, Mock Interview, Interview Recordings, Resume Preparation, Resume Review
- Mega Test:
- Grand Test:
AI summary & chapters
AI Summary
An AI-generated summary of this video lecture.
This video is a programming tutorial that teaches how to write a C program to check if a number is an Armstrong number. The instructor begins by introducing the concept of an Armstrong number, which is a number that is equal to the sum of its own digits each raised to the power of the number of digits. The lesson is structured around a step-by-step implementation. First, a function named `order` is defined to calculate the number of digits in a given number using a loop that repeatedly divides the number by 10. This function is then used in the main `isArmstrong` function. The `isArmstrong` function extracts each digit of the number, raises it to the power of the total number of digits (using the `pow` function), and accumulates the sum. Finally, the program compares this sum to the original number to determine if it is an Armstrong number. The tutorial includes a worked example using the number 153, which is confirmed to be an Armstrong number because 1^3 + 5^3 + 3^3 = 153. The video concludes with a demonstration of the complete code running in an online C compiler, showing the program's output.
Chapters
0:00 – 2:00 00:00-02:00
The video starts with the 'KNOX MEEHEGATF' logo, which is a stylized version of 'KNOWLEDGE GATE'. It then transitions to a screen showing the 'KNOWLEDGE GATE' brand and its social media handles. The main content begins with a C code snippet on a digital blackboard. The instructor introduces a function `int order(int x)` designed to calculate the number of digits in a number. The function initializes a counter `n` to 0 and uses a `while` loop that continues as long as `x` is greater than 0. Inside the loop, the counter `n` is incremented, and `x` is divided by 10. The loop terminates when `x` becomes 0, and the function returns the final count `n`. The instructor explains this logic, and on-screen text shows the code and a handwritten example `x=153` to illustrate the process.
2:00 – 5:00 02:00-05:00
The instructor continues to explain the `order` function, using the example `x=153`. He demonstrates the loop iteration by hand, showing that `n` starts at 0 and is incremented three times (n=1, n=2, n=3) as `x` is divided by 10 (153 -> 15 -> 1 -> 0). He confirms that the function correctly returns 3, which is the number of digits. The video then transitions to the main function, `int isArmstrong(int x)`. The instructor explains that this function will use the `order` function to get the number of digits `n`. He initializes a temporary variable `temp` to the input number `x` and a `sum` variable to 0. A `while` loop is used to process each digit of `temp`. Inside the loop, the last digit is extracted using `temp % 10`, and this digit is raised to the power of `n` using the `pow` function and added to the `sum`. The `temp` variable is then updated by integer division by 10. The instructor writes the formula `153 = 1^3 + 5^3 + 3^3` to illustrate the Armstrong condition.
5:00 – 7:19 05:00-07:19
The instructor completes the `isArmstrong` function by adding the final condition. After the loop, the function checks if the calculated `sum` is equal to the original number `x`. If true, it returns 1 (true); otherwise, it returns 0 (false). The video then shows the complete `main` function, which takes user input for a number `x`, calls `isArmstrong(x)`, and prints "True" or "False" based on the result. The final segment demonstrates the code running in the GDB Online compiler. The instructor runs the program with the input 153, and the output is "True", confirming that 153 is an Armstrong number. The video concludes with the program finishing with exit code 0.
The video provides a comprehensive, step-by-step guide to solving the Armstrong number problem in C. It begins with a foundational function to calculate the number of digits, which is a crucial step. This function is then integrated into the main logic, which iteratively processes each digit, applies the power operation, and accumulates the sum. The lesson effectively uses a concrete example (153) to illustrate the mathematical concept and the code's logic. The progression from function definition to the final main program, culminating in a live code execution, creates a clear and practical learning experience for students.

