C প্রোগ্রামের Function Argument সম্পর্কে আলোচনা

Submitted by tushar pramanick on Mon, 02/25/2013 - 10:36

Arguments to C Functions
You often need to pass a function some information before executing it. For example, in Listing 2.1 in Hour 2, a character string, "Howdy, neighbor! This is my first C program.\n", is passed to the printf() function, and then printf() prints the string on the screen.

 

Pieces of information passed to functions are known as arguments. The argument of a function is placed between the parentheses that immediately follow the function name.

 

The number of arguments to a function is determined by the task of the function. If a function needs more than one argument, arguments passed to the function must be separated by commas; these arguments are considered an argument list.

 

If no information needs to be passed to a function, you just leave the argument field between the parentheses blank. For instance, the main() function in Listing 2.1 of Hour 2 has no argument, so the field between the parentheses following the function name is empty.

 

The Beginning and End of a Function

As you may have already figured out, braces are used to mark the beginning and end of a function. The opening brace ({) signifies the start of a function body, while the closing brace (}) marks the end of the function body.

 

As mentioned earlier, the braces are also used to mark the beginning and end of a statement block. You can think of it as a natural extension to use braces with functions because a function body can contain several statements.

Comments

Related Items

The if-else Statement

The if-else Statement

The if statement

The if statement

If life were a straight line, it would be very boring. The same thing is true for programming. It would be too dull if the statements in your program could only be executed in the order in which they appear.

Mathematical Functions in C

Mathematical Functions in C

Basically, the math functions provided by the C language can be classified into three groups:

    Trigonometric and hyperbolic functions, such as acos(), cos(), and cosh().

Changing Data Sizes

Changing Data Sizes

Enabling or Disabling the Sign Bit

Enabling or Disabling the Sign Bit

As you know, it's very easy to express a negative number in decimal. All you need to do is put a minus sign in front of the absolute value of the number. But how does the computer represent a negative number in the binary format?