Vous êtes sur la page 1sur 3

Parameters(also called formal parameters) or arguments are the special identifiers through which information can be passed to the

function

Arguments are used mostly in functions (or methods). Basically it can be any input parameter(s) which a function(s) can use to do it's work. For instance, sin(x) sinus is a function and x is it's argument.
The mechanism used to convey information to the function is the argument. You have unknowingly used the arguments in the printf( ) and scanf( ) functions; the format string and the list of variables used inside the parentheses in these functions are arguments. The arguments are sometimes also called parameters. Short char The only valid modifier for char data type in C/C++ is signed and unsigned; short and long modifiers are only used for integer data type int. The primitive integral types in C/C++ are: char and int:
char c; // safe range 0~127 (because depending on the compiler settings, it is either -128~127 or 0~255) int i; // range -32768 ~ 32767 (16 bit) or -2147483648 ~ 2147483647 (32 bit) Using signed/unsigned and short/long modifiers, the set of integral data types would be: char c; // safe range 0~127 signed char sc; // -128~127 unsigned char uc; // 0~255 int i; // range -32768 ~ 32767 (16 bit) or -2147483648 ~ 2147483647 (32 bit) signed int si; // exactly the same as int. unsigned int ui; // 0~65535 or 0~4294967295 signed si1; // the same as signed int unsigned ui1; // the same as unsigned int short int s; // range -32768~32767 long int l; // -2147483648 ~ 2147483647 short s1; // the same as short int long l1; // the same as long int unsigned short int usi; // 0~65535 (may be abbreviated to unsigned short) unsigned long int uli; // 0~4294967295 (may be abbreviated to unsigned long).

BC0034-4.5 The type char


The type char

A single character can be defined as a character(char) type data. Characters are usually stored in 8 bits (one byte) of internal storage. The qualifier signed or unsigned may be explicitly applied to char. While unsigned chars have values between 0 and 255, signed chars have values from 128 to 127. A character constant is formed by enclosing the character within a pair of single quote marks. So b, . and 5 are all valid examples of character constants. Note that a character constant, which is a single character enclosed in single quotes is different from a character string, which is any number of characters enclosed in double quotes. The format characters %c can be used in a printf statement to display the value of a char variable at the terminal. Program 4.5: The following program illustrates how to use char data type. #include<stdio.h> main() { char c=A; int a=65; printf(%c\n, c); printf(%d\n, c); printf(%c\n,a); } Output A 65 A Note that with the format characters %d, the ASCII number of the character is displayed. With the format character %c, the character corresponding to the given ASCII number is displayed.
.

BC0034-2.4 The rules for naming Variables


The rules for naming Variables Within limits, you can give your variables and functions any names you want. These names (the formal term is identifiers) consist of letters, numbers, and underscores. For our purposes, names must begin with a letter. Theoretically, names can be as long as you want, but extremely long ones get tedious to type after a while, and the compiler is not required to keep track of extremely long ones perfectly. (What this means is that if you were to name a variable, say, supercalafragalisticespialidocious, the compiler might get lazy and pretend that youd named it super- calafragalisticespialidocio, such that if you later misspelled it supercalafragalisticespialidociouz, the compiler wouldnt catch your mistake. Nor would the compiler necessarily be able to tell the difference if for some perverse reason you deliberately declared a second variable named supercalafragalisticespialidociouz.) The capitalization of names in C is significant: the variable names variable, Variable, and VARIABLE (as well as silly combinations like variAble) are all distinct. A final restriction on names is that you may not use keywords (the words such as int and for which are part of the syntax of the language) as the names of variables or functions (or as identifiers of any kind).

Vous aimerez peut-être aussi