bool islower(char)To use/invoke/call the function (correct syntax).
char c;
cin >> c;
// call the function, pass it the value of variable c.
//It returns false or true, used here as condition of the if
if (islower(c))
cout << "It's a lowercase letter";
else
cout << "It's not a lowercase letter";
-------------------
do {
cin >> c;
} while (!islower(c)); //return value is logically negated.
-------------------
// unlikely code, but illustrates function's
//return value; what it evaluates to
cout << islower(c); // 0 or 1 output (bool converted to 0 or 1)
int i;
i = islower(c) * 3; //i will be 0 or 3
// character constant argument, also unlikely code since know the g is lowercase
cout << islower('g'); // output 1
cout << islower('$'); // output 0
**********************
double sqrt (double) One arg (double), return value is double.
cin >> f;
cout << sqrt(f); // f unchanged
cout << sqrt(f) / 2; // half of sqrt of f
cout << sqrt(f/2); // sqrt of half f
cout << sqrt(sqrt(f)); // fourth root of f
cout << sqrt(2); // arg is int, but compiler converts to double.
//cmath has prototype which informs compiler
about args and return type
y = sqrt(x); // x unchanged
x = sqrt(x); //x is now the sqrt of what it was
double pow (double,double)
Two args: first is double, second is double.
Returns double: the first arg raised to the second arg power.
cout << pow(x,y); // x to the y power
cout << pow(2,y); // 2 raised to the y power
cout << pow(x,0.5); // sqrt(x)
cout << pow(sqrt(x),y); //some math
cout << pow(x,3); //x cubed
cout << pow(x,1.0/3); //cube root of x
********************************************
char toupper (char)
One arg,:char. Returns char: the uppercase version of the arg. The arg
itself is not changed.
char c1, c2;
cin >> c1;
cout << toupper(c1); // c1 unchanged
cout << toupper('a'); // A output
c2 = toupper(c1);
cout << c2;
c1 = toupper(c1); // c1 now uppercase version of what it was
Next (making functions)