Find second largest number from given 3 numbers

Duration: 3 min

This video lesson is available to enrolled students.

Return to /learn/TCS-NQT-PREPARATION/advanced-coding/coding-questions/coding-question/asset-find-second-largest-number-from-given-3-numbers 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 educational video, presented by a 'Placement Expert' from Knowledge Gate, is a C programming tutorial focused on solving algorithmic problems involving comparisons of integers. The lecture begins by introducing a problem (Q9) to find the second largest number among three given integers, providing input/output specifications and test cases. The instructor then displays a C code solution that uses nested if-else statements to compare the three numbers and determine the second largest. The logic is broken down into cases: first, it checks if the first number is the largest, then compares the other two; if not, it checks if the second number is the largest, and so on. The video transitions to a second problem (Q8) to find the smallest of four numbers, showing a different approach using a variable 'min' initialized to the first number and updated through sequential comparisons. The final segment demonstrates the code execution in an online C compiler, showing the program being compiled and run with sample inputs, confirming the correct output. The overall teaching style is direct, using a digital blackboard to write and explain code, with the instructor providing commentary throughout.

Chapters

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

    The video opens with the 'Knowledge Gate' logo, followed by a slide introducing the channel's social media handles. The main content begins with a presentation slide for problem Q9: 'Find out second largest numbers of 3 numbers'. The slide details the input (three integers) and output (the second largest number) and provides two public test cases: one with inputs -4 0 4 yielding output 0, and another with 101 101 98 yielding output 101. The instructor then transitions to a code editor, displaying a C program. The code includes the standard header, a main function, and variables 'a', 'b', and 'c'. It prompts the user to 'Enter 3 numbers', reads them, and uses a complex nested if-else structure to determine the second largest. The logic first checks if 'a' is the largest, then compares 'b' and 'c' to find the second largest. If 'a' is not the largest, it checks if 'b' is the largest, and so on. The instructor explains this logic, with the code visible on the screen, and a 'Code' label in the top right corner.

  2. 2:00 – 2:38 02:00-02:38

    The video transitions to a new problem, Q8: 'Find out smallest of 4 numbers (numbers are not equal)'. The slide shows the problem statement and two test cases: inputs -2 0 2 yielding output -2, and 1875 690 2017 yielding output 690. The instructor then displays a new C code snippet for this problem. The code declares four integers 'a', 'b', 'c', 'd' and a variable 'min'. It reads the four numbers and initializes 'min' to 'a'. It then uses a series of if statements to compare 'b', 'c', and 'd' with 'min', updating 'min' if a smaller number is found. The final output is the value of 'min'. The instructor explains this method of finding the minimum. The video then shows the code being executed in the 'OnlineGDB' compiler. The program is compiled successfully, and the user is prompted to 'Enter 3 numbers'. The instructor types '1 2 3' as input, and the program outputs '2', which is the second largest number, confirming the logic of the previously shown code.

The video presents a structured, step-by-step tutorial on solving two fundamental programming problems in C: finding the second largest of three numbers and the smallest of four numbers. It demonstrates two distinct algorithmic approaches: a complex, case-based logic using nested conditionals for the first problem, and a simpler, iterative method using a 'min' variable for the second. The progression from problem definition to code implementation and finally to live execution in a compiler provides a comprehensive learning experience, reinforcing the concepts of input/output, conditional logic, and variable manipulation.

Loading lesson…