Printf & Scanf

Duration: 7 min

This video lesson is available to enrolled students.

Enroll to watch — RSSB (Basic Computer Instructor)

AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This lecture introduces C functions, beginning with the distinction between library and user-defined functions. Library functions such as printf() and scanf() are pre-written routines grouped together by compiler developers, while user-defined functions like argentina() and brazil() are created by the programmer. The instructor explains that using separate functions avoids rewriting identical code repeatedly and makes programs easier to design, track, and understand by dividing operations into modular activities. The lesson then moves to passing values between functions, using a C example where main() declares int a, b, c, sum; reads input with scanf(), and calls sum = calsum(a,b,c);. The called function calsum(x,y,z) declares int d;, computes d = x + y + z;, and returns d. The sample run shows the prompt “Enter any three numbers” followed by 10 20 30. The instructor contrasts two formal-argument declaration styles: the Kernighan and Ritchie (K&R) method, calsum(x,y,z) with int x,y,z; inside the body, and the ANSI method, calsum(int x,int y,int z), which is more commonly used today. A fun() program with two return statements and a printf prompt “Enter any alphabet” is shown, with output values 60 and 30. The instructor emphasizes that arguments passed to a called function are copied rather than physically moved, and the final slide introduces the Scope Rule of Functions with a main() program that calls display(i).

Chapters

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

    The lecture opens by stating that there are basically two types of functions: library functions, exemplified on-screen as printf() and scanf(), and user-defined functions, shown with examples argentina() and brazil(). The instructor explains that library functions are commonly required routines grouped together and stored on disk, written by compiler developers. Red strikethroughs appear over the two bullet points as the explanation progresses, and the slide transitions to “Why Use Functions,” where the first benefit is that writing functions avoids rewriting the same code over and over.

  2. 2:00 5:00 02:00-05:00

    The “Why Use Functions” slide continues, noting that using functions makes programs easier to write and keep track of, and that separating code into modular functions makes the program easier to design and understand. The instructor uses a triangle-area example and compares functions to a mechanic servicing a motorbike in the same way. The lesson then moves to “Passing Values between Functions,” showing a C listing where main() contains int a, b, c, sum;, a printf prompt, a scanf line, and the call sum = calsum(a,b,c);. The function calsum(x,y,z) declares int d;, computes d = x + y + z;, and ends with return(d);, while the bottom line reads “Enter any three numbers 10 20 30.”

  3. 5:00 7:13 05:00-07:13

    A slide contrasts two ways to declare formal arguments. The first shows calsum(x,y,z) with int x, y, z; identified as the Kernighan and Ritchie (or just K&R) method. The alternative, calsum(int x,int y,int z), is labeled the ANSI method and described as more commonly used these days. A fun() program appears with red circles around two return statements and the line printf("\nEnter any alphabet ");. The program output is listed as 60 and 30, and the instructor explains that values passed to a called function are copied rather than physically moved. The final slide is headed “Scope Rule of Functions” and shows a main() program that calls display(i).

The lecture builds from function classification to practical use. It first defines library versus user-defined functions, then justifies modular design by reducing code repetition and improving program clarity. The calsum example demonstrates how main() passes arguments to a called function, which computes and returns a value. The K&R versus ANSI comparison clarifies formal-argument declaration syntax, while the fun() example with two return statements and copied arguments reinforces control flow and data passing. The scope rule at the end sets up variable visibility across functions.

Loading lesson…