// important standard library functions

#include <iostream.h>
#include <stdlib.h>
#include <math.h>

void main()
{

  // math.h

  double angle, x, y, z;
  const double PI=3.14159265;

  angle=2*PI*double(1)/3;    //trig functions use angles in RADIANS
                             //360 degrees  ==   2*PI radians
 
  x=cos(angle);      //cosine
  x=sin(angle);      //sine
  x=tan(angle);      //tangent
  x=cot(angle);      //cotangent
  x=atan(angle);     //arc tangent
  x=acos(angle);     //arc cosine
  x=asin(angle);     //arc sine

  x=exp(2);          //x=e^2 , e is the natural base

  y=0.5;
  x=exp(y);          //x=e^(1/2)=square root of e

  x=sqrt(9.0);       //square root
  x=sqrt(y);
  x=sqrt(-1);        //ERROR -- can't take square root of negative number

  double z=6;
  x=pow(y,2);        //power function:  x=y^2
  x=pow(y,z);        //x=(y raised to the z)
  x=pow(y,0.5);      //x=y^(0.5) = square root y
  x=pow(y,-1);       //x=1/y=y^(-1)
  x=pow(-4,0.5);     //ERROR -- can't take square root of negative number

  x=log(y);          //natural logarithm
  x=log(exp(5));     //x=5

  x=abs(-4);         //absolute value (x==4)

  double a=3,b=2,c;
  c=sqrt(a*a+b*b-2*a*b*cos(angle));   //law of cosines


    //how to calculate cosine without using cos() function
  y=0.3;
  x=1 - y*y/2 + y*y*y*y/24;   //Taylor expansion for cos(y), when -1> x;                       //have user type in a number

///////////////////////////////////////////////////

  // stdio.h

  printf("Using printf!\n");     //display "Using printf!"

  //...also scanf, getch

///////////////////////////////////////////////////

  // stdlib.h

  int m;
  m=rand();          //rand() returns a random number between 0 and 32767
  
  m=rand();          //get another random number
  cout << m;         //display it
  cout << rand();    //cut out the middle-man, display another random number
  cout << rand();    //display another random number
  cout << rand();    //display another random number

  m=rand()%6;        //find the remainder after dividing random number 
                     //by 6; that remainder must be from 0 to 5; so
                     //net effect is to produce a random number from 0 to 5

  m=(rand()%100)+1;  //fill m with random number from 1 to 100

  srand(1324);       //"seed for the random number generator"
                     //each seed produces a different random sequence;
                     //same seed, same sequence

}