by Dinesh Thakur Category: Function and Pointer

We have seen that a function can be called from another function. In fact, the C language allows a function to be called from within itself. Such a function is called a recursive function.

 
by Dinesh Thakur Category: Function and Pointer

This program defines a function named func which has two parameters, a and b of type int. Within its body, this function first prints these parameter values, initializes them to 30 and prints them again. The main function declares two variables, a and b of type int. It first prints the values of these variables and then calls the function func with variables a and b as its arguments. Finally, the main function prints the values of variables a and b again.

 
by Dinesh Thakur Category: Function and Pointer

Another commonly required string operation is that of converting the case of a given string. The C standard library does not provide any function for case conversion. However, some C implementations provide the strlwr and strupr functions. The strlwr function converts all characters in a given string to lowercase, whereas the strupr function converts all characters to uppercase. Typical calls to these functions take the following forms:

 
by Dinesh Thakur Category: Function and Pointer

The length of a string is defined as the number of characters in it excluding the null terminator. The strlen function returns the length of a specified string. A typical call to this function takes the following form:

 
by Dinesh Thakur Category: Function and Pointer

So far we have studied functions that either return a value or have a void return type. A function can also return a pointer to a data item of any type. However, we must be careful while returning pointers from a function. A common mistake would be to return a pointer to a local variable or value parameter in that function as they are destroyed when control returns to the calling function.

 
by Dinesh Thakur Category: Function and Pointer

Every variable has a type associated with it which decides the values that can be assigned to it and the operations that can be performed on it. In addition, we can specify a storage class for a variable which decides the following:

 
by Dinesh Thakur Category: Function and Pointer

A standard C header file contains the declarations or prototypes of functions of a particular category. A function 'prototype usually specifies the type of value returned by that function, the function name and a list specifying parameter types as

 
by Dinesh Thakur Category: Function and Pointer

The clock function is used to determine the processor time in executing a program or part of a program. The header file <time.h> should be included in the program for its application. The function prototype is given below.

 
by Dinesh Thakur Category: Function and Pointer

Random number generation is a very useful facility in many programming situations, particularly gaming and simulation. We can also use it to generate test data for programs, particularly when a large amount of data is required. This saves a lot of time on data entry.

 
by Dinesh Thakur Category: Function and Pointer

The trigonometric and hyperbolic functions provided in the standard mathematical library are listed in Table. Except for the atan2 function, which takes two arguments, all other functions take a single argument and each function returns a single value. Note that the function parameters and return values are of type double.

 

Page 4 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