Q10 - Precedence and Associativity

Duration: 3 min

This video lesson is available to enrolled students.

Return to /learn/COCUBES-PREPARATION/coding/programming-in-c/c-by-yash-sir/asset-q10-precedence-and-associativity 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.

The video presents a coding problem involving the C++ modulus operator with a negative divisor. The question asks for the value of the expression `int x = 4 + 2 % (-8);`. The instructor first analyzes the expression by applying the order of operations, noting that the modulus operation `%` has higher precedence than addition. He then explains the mathematical rule for the sign of the modulus result, which is the same as the sign of the dividend (the number being divided). In this case, 2 is the dividend, so `2 % (-8)` evaluates to 2. The final result is `4 + 2`, which is 6. To confirm this, the instructor switches to a C++ online compiler, types the code, and runs it, showing the output as 6, thereby validating the theoretical calculation.

Chapters

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

    The video begins with a question displayed on a whiteboard: `Q. The expression, int x = 4 + 2 % (-8); evaluates to:` with four options: (1) -6, (2) 6, (3) 4, (4) None of these. The instructor, Yash Jain, starts to solve the problem by writing the expression `4 + 2 % (-8)` on the board. He then performs a long division of 2 by -8, writing `8)2` and showing that 8 goes into 2 zero times with a remainder of 2. He concludes that `2 % (-8)` is 2. He then adds this to 4, writing `4 + 2` and getting the result 6. He circles the number 6 on the board, indicating it as the answer. He also writes a general rule: `a % (-b) = a % b` and `a % b` where `a < b`. He then writes `PUMA's REBL TAC` and `1234` with a circle around the number 3, possibly as a mnemonic or a joke.

  2. 2:00 – 2:48 02:00-02:48

    The instructor transitions from the whiteboard to a live coding environment, an online C++ compiler. He types the code `#include <iostream> using namespace std; int main() { int x = 4 + 2 % (-8); cout << x; }`. He then clicks the 'Run' button. The output console displays the result as `6`. This practical demonstration confirms the theoretical calculation from the whiteboard, showing that the expression evaluates to 6. The instructor's final answer is 6, which corresponds to option (2).

The video effectively combines theoretical explanation with practical verification. It first presents a common point of confusion in programming: the behavior of the modulus operator with negative numbers. The instructor uses a step-by-step mathematical approach to demonstrate that the sign of the result is determined by the dividend, not the divisor. This is a crucial concept for understanding the C++ modulus operator. The lesson is then solidified by a live coding demonstration, which provides empirical evidence for the theoretical result, reinforcing the learning objective and ensuring the student understands both the 'why' and the 'how' of the operation.

Loading lesson…