with Example C Programs
Subject and UNIT: Programming in C: Unit II (a): Arrays
There are three ways of passing two-dimensional arrays to functions. First, we can pass individual elements of the array. This is exactly same as passing elements of a one-dimensional array. Second, we can pass a single row of the two-dimensional array.
with Example C Programs
Subject and UNIT: Programming in C: Unit II (a): Arrays
Two-dimensional arrays can be used to implement the mathematical concept of matrices. In mathematics, a matrix is a grid of numbers, arranged in rows and columns. Thus, using two-dimensional arrays, we can perform the following operations on an m x n matrix
with Example C Programs
Subject and UNIT: Programming in C: Unit II (a): Arrays
Till now we have read only about one-dimensional arrays. A one-dimensional array is organized linearly and only in one direction. But at times, we need to store data in the form of matrices or tables.
with Example C Programs
Subject and UNIT: Programming in C: Unit II (a): Arrays
Like variables of other data types, we can also pass an array to a function. While in some situations, you may want to pass individual elements of the array, and in other situations you may want to pass the entire array.
with Example C Programs
Subject and UNIT: Programming in C: Unit II (a): Arrays
There are a number of operations that can be preformed on arrays. These operations include:Traversing an array, Inserting an element in an array, Deleting an element from an array, Merging two arrays, Searching an element in an array, Sorting an array in ascending or descending order
Programming in C
Subject and UNIT: Programming in C: Unit II (a): Arrays
When we declare an array, we are just allocating space for the elements; no values are stored in the array. To store values in the array, there are three ways-first, to initialize the array element at the time of declaration;
with Examples
Subject and UNIT: Programming in C: Unit II (a): Arrays
For accessing an individual element of the array, the array subscript must be used. For example, to access the fourth element of the array, we must write arr [3].
Subject and UNIT: Programming in C: Unit II (a): Arrays
We will explain the concept of arrays using an analogy. Take a situation in which we have 20 students in a class and we have been asked to write a program that reads and prints the marks of all these 20 students.
with Example C Programs
Subject and UNIT: Programming in C: Unit II (a): Arrays
We have already seen that every variable must be declared before it is used. The same concept is true in case of array variables also. An array must be declared before being used
with Example C Programs | Preprocessor Directives
Subject and UNIT: Programming in C: Unit I (d): Preprocessor Directives
There are certain predefined macros that are readily available for use by the C programmers. A list of such predefined macros is given in Table 10.2.
with Example C Programs | Preprocessor Directives
Subject and UNIT: Programming in C: Unit I (d): Preprocessor Directives
The #error directive is used to produce compiler-time error messages. The syntax of this directive is #error string.The error messages include the argument string.
with Example C Programs | Preprocessor Directives
Subject and UNIT: Programming in C: Unit I (d): Preprocessor Directives
We have seen that we can check the existence of a macro by using #ifdef directive. However, there is another way to do the same. The alternative to #ifdef directive is to use the defined unary operator.