SCOPE RULE OF FUNCTION

Duration: 3 min

This video lesson is available to enrolled students.

Return to /learn/INFOSYS-PREPARATION/programming-fundamentals/functions-ca695d/function-basics-definition-declaration-and-calling-mechanisms/asset-scope-rule-of-function after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Reasoning Ability: Seating Arrangements, Syllogisms, Coding Decoding, Series (Number and Letter Series) (Numerical Relations and Reasoning), Crypt Arithmetic, Clock, Calendar, Data Sufficiency, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Blood Relations, Directions (Direction Test), Inequality
  2. Technical Ability (Aptitude): Percentage, Ratio and Proportion (Ratios), HCF LCM, Divisibility Rules, Average, Sequence and Series (Series), Number System, Permutation and Combination, Probability, Profit and Loss, Time and Work, Simple Interest and Compound Interest, Pipe and Cistern, Speed Time and Distance, Mixture and Alligation, Mensuration and Geometry, Age Problems, Partnership, Data Interpretation, Arithmetic, Powers and Exponents (Surds and Indices), Algebra, Statistics, Mental Ability
  3. Verbal Ability: Vocabulary, Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Sentence Correction (Error Correction), Sentence Completion (Fill in the blanks), Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Cloze Test (Cloze Passage), Verbal Analogy (Word Based Analogy), Sentence Construction, Facts, Inference and Judgements
  4. Programming Fundamentals: C Fundamentals, Control Flow, Functions, Arrays & Pointers, Storage Classes, Structures & Enums
  5. Coding: Coding Questions by Yash Sir, C Programming by Yash Sir, Python for Placements by Yash Sir, DSA using Python, Object Oriented Programming (OOPS)
  6. Pseudo Code: Pseudo Codes
  7. Puzzle Solving: Puzzle Solving (Puzzles)
  8. English Grammar: Noun, Pronoun, Adjectives, Preposition, Articles, Direct and Indirect Speech, Tenses, Conjunction, Subject Verb Agreement (Verb Noun Agreement), Modals, Active Passive Voice (Voice), Determiner, Adverb, Verb
  9. Essay Writing: English Writing Ability
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

The lecture begins by examining the scope rules of functions in C, using a code example where main() calls display(). The instructor emphasizes that variables like i in main and k in display are local and inaccessible to other functions without explicit passing or returning. He then transitions to calling conventions, explaining that C passes arguments from right to left. This is demonstrated with a complex printf statement involving increment operators, where he writes the output 3 3 1 to show the evaluation order. The session concludes by addressing printf's variable argument list, noting that mismatched format specifiers compile but cause runtime garbage output. Finally, he introduces advanced features like function prototypes and the default int return type for functions.

Chapters

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

    The instructor presents a C program with main() and display() functions to illustrate scope. He writes int j != 20 on the screen to clarify that the parameter j does not automatically take the value of i from main. He explains that scope is local to the function definition. He then introduces Calling Convention, stating C passes arguments right-to-left. He writes 3 3 1 under a printf example printf("%d %d %d", a, ++a, a++) to demonstrate how the right-to-left evaluation affects the output when side effects are involved. He notes that while simple calls like fun(a, b, c, d) are unaffected by order, complex expressions depend on it.

  2. 2:00 – 2:55 02:00-02:55

    The lecture shifts to printf behavior with mismatched arguments. The code printf("%d %d %d", i, j); is shown, where only two variables are provided for three format specifiers. The instructor explains this compiles because printf accepts a variable number of arguments, but prints garbage at runtime. He then lists Advanced Features of Functions, including prototypes and recursion. He explains that functions default to returning int unless specified otherwise, necessitating explicit declaration for other types. He sets up a simple program to find the square of a number to demonstrate this.

The video systematically builds understanding of C function mechanics, starting with variable scope limitations, moving to the specific right-to-left argument passing order, and concluding with the implications of variable arguments and default return types.

Loading lesson…