Convert Decimal to Octal

Duration: 3 min

This video lesson is available to enrolled students.

Return to /learn/TCS-NQT-PREPARATION/advanced-coding/coding-questions/coding-question/asset-convert-decimal-to-octal after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. TCS One Shot Free Videos & Notes: TCS Preparation
  2. 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
  3. 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
  4. New Pattern-Verbal Ability (Foundation Section): Sentence Completion (Fill in the blanks), English Writing Ability
  5. 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
  6. Advanced Quantitative Ability: TCS NQT Advanced Quantitative Ability
  7. Advanced Reasoning Ability: TCS NQT Advanced Reasoning Ability
  8. 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
  9. TCS Full Length Mock Test:
  10. TCS Interview & Resume Prep: MR & HR Interview Preparation, TCS Interview Preparation, Mock Interview, Interview Recordings, Resume Preparation, Resume Review
  11. Mega Test:
  12. Grand Test:
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This video is a programming tutorial from Knowledge Gate that teaches how to convert a decimal number to an octal number. The lesson begins with an introduction to the problem, which is to write a C program to convert a decimal number to octal. The instructor first explains the manual conversion process using the division-by-8 method, demonstrating it with the decimal number 33, which results in the octal number 41. The video then transitions to the coding part, where the instructor displays a C program. The code uses a loop to repeatedly divide the input number by 8, collecting the remainders to form the octal number. The instructor walks through the code, explaining the logic and variables, and demonstrates the step-by-step calculation of the octal equivalent of 33, showing how the final result is built digit by digit.

Chapters

  1. 0:00 – 2:00 00:00-02:00

    The video starts with the Knowledge Gate logo, followed by a slide showing the company's various educational offerings. The main content begins with a PowerPoint presentation titled 'Q2: Write a program to convert Decimal to Octal'. The instructor, identified as a 'Placement Expert', introduces the topic. The screen then displays a diagram under the heading 'Logic' that illustrates the manual conversion of the decimal number 33 to octal. The process involves dividing 33 by 8, which gives a quotient of 4 and a remainder of 1. Then, 4 is divided by 8, giving a quotient of 0 and a remainder of 4. The remainders are read in reverse order to get the octal number 41. The instructor explains this logic, emphasizing the division-by-8 method.

  2. 2:00 – 2:41 02:00-02:41

    The video transitions to the 'Code' section, where a C program is displayed on the screen. The code includes the standard header file, a main function, and variables for the input number (n), a temporary variable (dn), a variable to store the octal result (binno), and loop counters (i, j). The program uses a for loop to repeatedly divide the number by 8. The instructor explains the logic, noting that the remainder of each division (n%8) is added to the result (binno) after being multiplied by a power of 10 (i). The variable 'i' is multiplied by 10 in each iteration to shift the place value. The instructor demonstrates the calculation step-by-step, showing that for n=33, the first iteration gives a remainder of 1, which is added to binno (0 + 1*1 = 1). The second iteration gives a remainder of 4, which is added to binno (1 + 4*10 = 41). The final printf statement outputs the result, confirming the octal of 33 is 41.

The video provides a comprehensive, step-by-step tutorial on converting a decimal number to octal, covering both the theoretical logic and its practical implementation in C. It begins with a clear explanation of the manual division method, using a worked example to build understanding. This foundational knowledge is then directly applied to the programming solution. The instructor bridges the gap between the algorithm and the code by walking through the C program, explaining each line and variable, and demonstrating the calculation process. This approach ensures that students not only learn the code but also understand the underlying mathematical principle, making the lesson effective for both beginners and those looking to solidify their programming fundamentals.

Loading lesson…