by Dinesh Thakur Category: Function and Pointer

Functions may be return type functions and non-return type functions. The non-return type functions do not return any value to the calling function; the type of such functions is void. These functions may or may not have any argument to act upon. A few illustrations of such functions are given below.

 
by Dinesh Thakur Category: Function and Pointer

As we know, the expression x [i] to access the ith element of vector x can be equivalently written using pointer notation as * (x+i) . Thus, the expression a [i] [j] to access the ijth element of matrix a can be equivalently written as * (*(a+i) +j). Observe that this expression is obtained by applying twice the construct used for a vector. The address of a [i][j] is thus given as * (a+i) +j. These results are summarized below.

 
by Dinesh Thakur Category: Function and Pointer

exit () is used to exit the program as a whole. In other words it returns control to the operating system.

After exit () all memory and temporary storage areas are all flushed out and control goes out of program. In contrast the return statement is used to return from a function and return control to the calling function.



 
by Dinesh Thakur Category: Function and Pointer

If elements of an array are two-dimensional arrays, the array is called a three-dimensional array. Therefore, a three-dimensional array may be considered as an array of matrices. Let Arm be a 3-dimensional array or an array of matrices. The declaration of pointer and its initialization is carried out as given below.

 
by Dinesh Thakur Category: Function and Pointer

The return statement is used to terminate the execution of a function and transfer program control back to the calling function. In addition, it can specify a value to be returned by the function. A function may contain one or more return statements. The general format of the return statement is given below.

 
by Dinesh Thakur Category: Function and Pointer

When a C program is compiled, the compiler allocates memory to store different data elements such as constants, variables (including pointer variables), arrays and structures. This is referred to as compile-time or static memory allocation. There are several limitations in such static memory allocation:

 
by Dinesh Thakur Category: Function and Pointer

The name or identifier of an array is itself a constant pointer to the array. Its value is the address of the first element of the array. Thus, a pointer to an array may be declared and assigned as shown below.

 
by Dinesh Thakur Category: Function and Pointer

An individual element of an array may be regarded as a variable of the type declared in the declaration of the array. All the operators that can be applied to a variable of that type are applicable to the elements of array as well. Program, the array elements are subjected to arithmetic operations with the help of pointers.

 
by Dinesh Thakur Category: Function and Pointer

The Tower of Hanoi problem consists of three poles, left, middle, and right. One of the poles (say, the left) contains n disks of different sizes placed on each other, as shown in Fig. The objective of the problem is to transfer all the disksfrom the left pole to right pole such that only one disk can be moved at a time (to any pole) and a larger  disk cannot be placed on top of a smaller disk.

 
by Dinesh Thakur Category: Function and Pointer

We can use typecast operator to convert the type of value returned by a pointer dereference expression to another suitable type. For example, if pa is a pointer to a variable a of type int, we can use typecast as (double) *pa to convert the integer value of *pa to type double.

 

Page 3 of 8

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article