The SQRT Function
The SQRT Function
Computer Applications
Source code:
#include <iostream>
#include <cmath>
#include <conio.h>
using namespace std;
int main()
{
double param, result;
param=123.45;
result=sqrt(param);
cout<<"sqrt("<<param<<") = "<<result<<endl;
getch();
return 0;
}
Screen output:
Source code:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double resultx,resulty;
resultx=pow(5,3);
cout<<"5 raised to the power of 3 is "<<resultx<<endl;
resulty=pow(3,4);
cout<<"3 raised to the power of 4 is "<<resulty<<endl;
return 0;
}
Screen output:
cmath functions:
cctype functions
1. tolower - The tolower() function converts ch to its lowercase version if it exists. If the
lowercase version of a character does not exist, it remains unmodified. The uppercase
letters from A to Z is converted to lowercase letters from a to z respectively. The
behaviour of tolower() is undefined if the value of ch is not representable as unsigned
char or is not equal to EOF. It is defined in <cctype> header file.
2. toupper - The toupper() function converts ch to its uppercase version if it exists. If the
uppercase version of a character does not exist, it remains unmodified. The lowercase
letters from a to z is converted to uppercase letters from A to Z respectively. The
behaviour of toupper() is undefined if the value of ch is not representable as unsigned
char or is not equal to EOF. It is defined in <cctype> header file.
cstdlib functions
1. rand - One way to generate these numbers in C++ is to use the function rand(). Rand is
defined as: #include <cstdlib> int rand(); ... It is a number that is not truly random, but
appears random. That is, every number between 0 and RAND_MAX has an equal chance
(or probability) of being chosen each time rand() is called.
2. srand -The srand() function in C++ seeds the pseudo random number generator used by
the rand() function. The seed for rand() function is 1 by default.
It means that if no srand() is called before rand(), the rand() function behaves as if it was
seeded with srand(1).