Having multiple condition inside a loop
Duration: 14 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 educational video is a lecture on C programming, specifically focusing on multiple-choice questions (MCQs) related to loops, which are a common topic in competitive exams like GATE and TCS NQT. The instructor, Yash Jain, begins with an introduction to the topic, followed by a detailed analysis of a C code snippet that uses a 'for' loop with a 'double' variable. He explains that due to floating-point precision issues, the loop condition `k < 3.0` may never become false, leading to an infinite loop, which is the correct answer. The video then transitions to another MCQ involving a 'while' loop with a comma operator in the condition, which is syntactically incorrect. The instructor demonstrates that the comma operator evaluates to the last expression, making the condition `j < 10`, but the syntax of the 'while' loop is invalid because it lacks a proper condition. The final segment shows a third MCQ from TCS NQT 2019, where the instructor analyzes a 'while' loop with a comma operator in the condition, correctly identifying it as a syntax error. The video uses a digital blackboard for code and explanations, with the instructor providing a clear, step-by-step walkthrough of each problem.
Chapters
0:00 – 2:00 00:00-02:00
The video opens with a title slide for a C programming MCQs lecture by Yash Jain. The slide features a glowing blue keyboard and a small diagram of a presentation screen. The instructor then transitions to a new slide with a large golden 'C' and a laptop displaying 'Loops in C'. The main content area shows a C code snippet with a 'for' loop using a 'double' variable 'k'. The instructor begins to analyze the code, pointing out the loop condition `k < 3.0` and the increment `k++`. He explains that the loop will run infinitely because of floating-point precision issues, where the value of 'k' may never exactly reach 3.0, making the condition always true. The options for the MCQ are listed below the code.
2:00 – 5:00 02:00-05:00
The instructor continues to analyze the first MCQ. He writes on the digital blackboard, explaining the loop's behavior. He notes that the loop starts with `k = 0.0` and increments by 1.0 each time. He demonstrates that the loop will run for `k = 0.0, 1.0, 2.0`, but when `k` becomes `3.0`, the condition `k < 3.0` is false, so the loop should terminate. However, he points out that due to floating-point representation, `k` might be `2.999999` or `3.000001`, which could cause the loop to run one more time or never terminate. He concludes that the loop will run infinitely, making option (b) the correct answer. He then moves to the next MCQ, which involves a 'while' loop with a comma operator in the condition.
5:00 – 10:00 05:00-10:00
The instructor analyzes the second MCQ, which contains a 'while' loop with the condition `i<5,j<10`. He explains that the comma operator evaluates the left expression, then the right, and returns the value of the right expression. Therefore, the condition becomes `j<10`. However, he points out that the syntax of the 'while' loop is incorrect because the condition is not properly enclosed in parentheses. He writes on the board, showing that the correct syntax should be `while (i<5, j<10)`. He concludes that this is a syntax error, making option (a) the correct answer. He then moves to the third MCQ, which is from TCS NQT 2019.
10:00 – 14:09 10:00-14:09
The instructor presents the third MCQ, which is from TCS NQT 2019. The code shows a 'while' loop with the condition `i=5,j<10`. He explains that the comma operator evaluates the left expression `i=5` (which assigns 5 to i) and then the right expression `j<10`, returning the value of the right expression. However, he points out that the syntax is incorrect because the condition is not properly enclosed in parentheses. He writes on the board, showing that the correct syntax should be `while (i=5, j<10)`. He concludes that this is a syntax error, making option (a) the correct answer. The video ends with the instructor summarizing the key points and encouraging students to practice more MCQs.
The video provides a comprehensive analysis of C programming MCQs related to loops, focusing on common pitfalls and syntax errors. The instructor systematically breaks down each problem, using a digital blackboard to illustrate the logic and code execution. The key learning points are the importance of understanding floating-point precision in loop conditions and the correct syntax for using the comma operator within control structures. The progression from a conceptual problem (infinite loop due to precision) to a syntactic problem (incorrect loop condition) effectively demonstrates the range of issues students might encounter in competitive exams.

