Absolute C++ Chapter 3 Self-Test Exercise(1)

1.16.01/2    161/2    2.03.0

23   2.03   1.12

|3|  |-3|  |0|

|-3.0|  |-3.5|  |3.5|

2.sqrt(x+y)  pow(x,y+7)  sqrt(area+fudge)

sqrt(time+tide)/nobody  (-b+sqrt(pow(b,2)-4*a*c))/(2*a)

abs(x-y)

3.

#include<iostream>
#include
<cmath> using namespace std;

int main()

{

  for(int i=1,i<=10,i++)

  {

    root=sqrt(i);

    cout<<"the square root for "<<i<<"is "<<root<<endl; 

  }

  return 0;

} 

4.to show the case why you wanted to end the program.

5. rand()%10

6.

#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
  int s;
  cout<<"Enter a whole number: ";
  cin>>s;
  srand(s);
  for(int i=0,i<10,i++)
  {
    random=rand()/static_cast<double>(1.0);
    cout<<random;
  }
  return 0;
}
posted @ 2012-05-07 10:38  terryhan  阅读(184)  评论(0)    收藏  举报