Programming and Graphics

(Kiana) #1

68 Introduction to C++ Programming and Graphics


3.4.5.What is the output of the following code?


#include <iostream>
using namespace std;

int main()
{
int diosmos=1;

for (diosmos==1;diosmos<=4;diosmos++)
{
switch(diosmos)
{
case 1:{cout << "Two ";}
break;
case 2:{cout << "gallons ";}
break;
case 3:{cout << "of milk" << endl};
}
break;
default:{cout << "please!!!" << endl;}
}
}
return 0;
}

3.4.6.Compute the greatest common divisor of 1986 and 343.


3.5 Mathematical library.........................


Table 3.5.1 lists functions of the C++ mathematical library. To use these
functions, the associated header file must be included at the beginning of the
program by stating:


#include<cmath>

For example, to compute the exponential of a numbera, we write:

#include<cmath>

float a = 2.3;
float b = exp(a);

Equally well, we can write


double b = exp(2.3);
Free download pdf