c language tutorial

Strings in C Language

Strings are actually one-dimensional array of characters terminated by a null character . Thus a null-terminated string contains the characters that comprise the string followed by a null.

Character arrays in C Language

array of characters terminated by a null character ‘\0’. Thus a null-terminated string contains the characters that comprise the string followed by a null. The following declaration and initialization create a string consisting of the word “Hello”. To hold the null character at the end of the array, the size of the character array containing […]

Multi dimensional arrays in C Language

C programming language allows multidimensional arrays. Here is the general form of a multidimensional array declaration − type name[size1][size2]…[sizeN]; For example, the following declaration creates a three dimensional integer array − int threedim[5][10][4]; Two-dimensional Arrays The simplest form of multidimensional array is the two-dimensional array. A two-dimensional array is, in essence, a list of one-dimensional […]

Manipulating array elements in C Language

An element is accessed by indexing the array name. This is done by placing the index of the element within square brackets after the name of the array. For example − double salary = balance[9]; The above statement will take the 10th element from the array and assign the value to salary variable. The following […]

Array notation and representation in C Language

Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. Instead of declaring individual variables, such […]

Recursive functions in C Language

Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function. void recursion() { recursion(); /* function calls itself */ } int main() { recursion(); } The C programming […]

Call by reference in C Language

The call by reference method of passing arguments to a function copies the address of an argument into the formal parameter. Inside the function, the address is used to access the actual argument used in the call. It means the changes made to the parameter affect the passed argument. To pass a value by reference, […]

Call by value in C Language

The call by value method of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument. By default, C programming uses call by value to pass arguments. In general, […]

Passing parameters to functions in C Language

If a function is to use arguments, it must declare variables that accept the values of the arguments. These variables are called the formal parameters of the function. Formal parameters behave like other local variables inside the function and are created upon entry into the function and destroyed upon exit. While calling a function, there […]

functions with array in C Language

If you want to pass a single-dimension array as an argument in a function, you would have to declare a formal parameter in one of following three ways and all three declaration methods produce similar results because each tells the compiler that an integer pointer is going to be received. Similarly, you can pass multi-dimensional […]

1 7 8 9 10 11 13