Check whether a number is armstrong by calculation order

Duration: 7 min

This video lesson is available to enrolled students.

Return to /learn/COCUBES-PREPARATION/coding/coding-questions/coding-question/asset-check-whether-a-number-is-armstrong-by-calculation-order after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Quantitative Aptitude: Number System, Divisibility Rules, HCF LCM, Percentage, Ratio and Proportion (Ratios), Average, Profit and Loss, Simple Interest and Compound Interest, Mixture and Alligation, Partnership, Age Problems, Time and Work, Pipe and Cistern, Speed Time and Distance, Algebra, Arithmetic, Data Interpretation, Sequence and Series (Series), Logarithm, Powers and Exponents (Surds and Indices), Permutation and Combination, Probability, Speed Mathematics and Basic Mathematics, Trigonometry
  2. Logical Reasoning: Coding Decoding, Blood Relations, Directions (Direction Test), Ranking, Order and Sequence, Seating Arrangements, Puzzle Solving (Puzzles), Data Arrangement, Syllogisms, Inequality, Data Sufficiency, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Series (Number and Letter Series) (Numerical Relations and Reasoning), Venn Diagram, Logical Sequence Of Words, Calendar, Clock, Cubes & Dices, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning)
  3. Verbal Ability: Noun, Pronoun, Adjectives, Verb, Adverb, Tenses, Subject Verb Agreement (Verb Noun Agreement), Articles, Preposition, Conjunction, Modals, Determiner, Vocabulary, Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Cloze Test (Cloze Passage), Sentence Correction (Error Correction), Sentence Completion (Fill in the blanks), Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Active Passive Voice (Voice), Direct and Indirect Speech, Sentence Construction
  4. Data Structures (Domain Test): Introduction to DS, Array, Stack, Queue, Linked List, Tree, Graphs, Hashing
  5. Algorithms (Domain Test):
  6. OOPs (Domain Test): Object Oriented Programming (OOPS)
  7. DBMS (Domain Test): Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Decomposition Properties & 4NF, File Organization & Indexing, Relational Algebra, Relational Calculus, Transaction Management, Concurrency Control, Database Recovery, ORDBMS, Database Security & Authorization, Query Processing & Optimization, Enhanced Data Models, Data Warehousing & Mining, Big Data Systems, NoSQL
  8. SQL (Domain Test): SQL
  9. Operating Systems (Domain Test): Introduction to OS, Process Management, CPU Scheduling, Process Synchronization, Deadlock, Threads & Process Creation, Memory Management, Virtual Memory, Disc Scheduling, File Management, Windows OS, Linux OS, Security, Distributed Systems, Virtual Machines
  10. Computer Networks (Domain Test): Introduction to CN, Data Communication, DLL: Access Control, DLL: Flow Control, DLL: Error Control, DLL: Framing, Data Link Layer - Ethernet, Net Layer: IPv4 & Proto, Net Layer: IP Addressing, Net Layer:Routing Protocol, Transport Layer Services, TL: Congestion & UDP, Application Layer, Hardware basics, Network Security, Cloud Computing and IoT, Cyber and Info Security
  11. Coding: Coding Questions by Yash Sir, C Programming by Yash Sir, Programming in C++, Java, Python for Placements by Yash Sir
  12. Written English Test: English Writing Ability
  13. Psychometric Test: Behavioral Assessment (Behavioral Competency Profiling) (Psychometric 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

  1. 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. 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.

  3. 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.

Loading lesson…