Author: learnconline

Multi-Dimensional Arrays in C Programming Language 3

Multi-Dimensional Arrays in C Programming Language

Let’s understand the concept of multi-dimensional arrays in C programming language. Although arrays with more than two dimensions are not commonly used, C does allow any number of dimensions to be declared. This is done by listing maximum size of all dimensions of the array. For example, the declaration: int a[4][10][6]; declares a three-dimensional array. The first element in the array is designated as a[0][0][0] and the last element as a[3][9][5]. Thus, generally speaking, multidimensional arrays in C programming language are defined in much the same manner as one-dimensional arrays, except that a separate pair of square brackets are required...

Compare Automatic, Register, Static and External Variables in C 2

Compare Automatic, Register, Static and External Variables in C

Let us understand the difference between various storage classes in C programming language. Below is the table that will show difference between Automatic, Register, Static and External Variables storage Classes in C. Feature Automatic Variable Register Variable Static Variable External Variable 1 Keyword Used auto register static extern 2 Storage Memory CPU registers Memory Memory 3 Default initial value Garbage Value Garbage Value Zero Value Zero Value 4 Scope Local to the block in which the variable is defined Local to the block in which the variable is defined Local to the block in which the variable is defined Global...

Operations on Pointers in C Programming Language 3

Operations on Pointers in C Programming Language

In C Programming Language, the only operations that can be carried out on pointers are summarized below: A pointer variable can be assigned the address of an ordinary variable (e.g., pv = &v) A pointer variable can be assigned the value of another pointer variable (e.g., pv = px) provided both the pointers point to objects of the same data-type A pointer variable can be assigned a null (zero) value (e.g., pv =NULL, where NULL is a symbolic constant that represents the value 0) An integer quantity can be added to or subtracted from a pointer variable (e.g., pv +...

Scope of Local and Global Variables in C Programming 1

Scope of Local and Global Variables in C Programming

The scope of variables refers to that portion of the program where the variables can be accessed. They are accessible in some portion of the program and in the other they are not accessible. Scope of a variable defines the portion of the program in which the set of variables can be referenced and manipulated. When a variable is required in a program, it can be declared as: Local variable Global variable Local Variables in C Programming Language The variables that are declared inside a function are called as local variables The scope is only within the function in which...

Coding Standards for Writing Functions 1

Coding Standards for Writing Functions

Whether its C programming language or C++ programming language or PHP, we should have a coding standard in place before starting with the code development. Coding standard is a predefined standard which should be followed during the code development which will improve the quality of the code. The coding standards varies from organization to organization. Each organization define their own coding standard and follow them to achieve the desired code quality. Here, we will define a coding standard for writing functions. Coding Standards for Writing Functions A function name should be preceded by fn The first character in the function...

How does using functions make writing large programs easier? 1

How does using functions make writing large programs easier?

Consider a program with 1000 lines. It is much easier to write a properly designed program consisting of 20 50-line functions than it is to write a program consisting of one 1000-line main program. Functions can be written, tested, and understood independently of one another. You can write a function, test it, and convince yourself that it is correct without worrying about the other functions in your program. It is much easier to get your mind around a 50-line thing than a 1000-line thing. Another benefit is that code can be reused between projects. If someone has previously written a...

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet