Category: 02. C
-
Global Variables in C
Global variables are defined outside a function, usually at the top of a program. Global variables hold their values throughout the lifetime of a program and they can be accessed inside any of the functions defined for the program. If a function accesses and modifies the value of a global variable, then the updated value is…
-
Static Variables in C
By default, a C variable is classified as an auto storage type. A static variable is useful when you want to preserve a certain value between calls to different functions. Static variables are also used to store data that should be shared between multiple functions. Static Variables The static variables belong to the static storage class, they are initialized only…
-
Scope Rules
A scope in any programming is a region of the program where a defined variable can have its existence and beyond that variable it cannot be accessed. There are three places where variables can be declared in C programming language − Let us understand what are local and global variables, and formal parameters. Local Variables Variables that are declared inside a function…
-
Recursion in C
Recursion is the process by which a function calls itself. C language allows writing of such functions which call itself to solve complicated problems by breaking them down into simple and easy problems. These functions are known as recursive functions. What is a Recursive Function in C? A recursive function in C is a function that calls itself. A…
-
Return Statement in C
The return statement terminates the execution of a function and returns control to the calling function. Every function should have a return statement as its last statement. While using the returns statement, the return type and returned value (expression) must be the same. Syntax of return Statement Here is the syntax of the return statement: The following main() function shows return as its…
-
Callback Function in C
Callback functions are extremely versatile, particularly in event-driven programming. When a specific event is triggered, a callback function mapped to it is executed in response to these events. This is typically used in GUI applications, an action like a button click can initiate a series of predefined actions. Callback Function The callback function is basically…
-
User-defined Functions in C
A function in C is a block of organized, reusable code that is used to perform a single related action. In any C program, there are one or more functions − classified as library functions and user-defined functions. There are two types of functions in C − Any C compiler (e.g. GCC compiler, Clang, MSVC compiler, etc.)…
-
Variadic Functions in C
Variadic functions are one of the powerful but very rarely used features in C language. Variadic functions add a lot of flexibility in programming the application structure. Variadic Function in C A function that can take a variable number of arguments is called a variadic function. One fixed argument is required to define a variadic function.…
-
Nested Functions in C
The term nesting, in programming context refers to enclosing a particular programming element inside another similar element. Just like nested loops, nested structures, etc., a nested function is a term used to describe the use of one or more functions inside another function. What is Lexical Scoping? In C language, defining a function inside another one…
-
Function Call by Reference in C
There are two ways in which a function can be called: (a) Call by Value and (b) Call by Reference. In this chapter, we will explain the mechanism of calling a function by reference. Let us start this chapter with a brief overview on “pointers” and the “address operator (&)”. It is important that you…