Page 88 - Modular_V1.1_Flipbook
P. 88
Program 2: To use mathematical functions.
Output:
#include<iostream.h>
The nearest integer of number is: -543
#include<math.h>
The absolute value of number is: 543.429993
#include<conio.h> The nearest round down value of number is: -544
void main() The remainder is: 1
{ The a raised to the power b is: 225
The square root of 144 is: 12
float number =-543.43;
The cosine of angle 45 degree is: 0.525322
float a = 15, b = 2;
The natural logarithm of the number 10 is: 2.302585
int angle = 45;
cout<<”The nearest integer of number is: “<<ceil(number);
cout<<”\nThe absolute value of number is: “<<fabs(number);
cout<<”\nThe nearest round down value of number is:”<<floor(number);
cout<<”\nThe remainder is: “<<fmod(a, b);
cout<<”\nThe a raised to the power b is: “<<pow(a,b);
cout<<”\nThe square root of 144 is: “<<sqrt(144);
cout<<”\nThe cosine of angle 45 degree is: “<<cos(angle);
cout<<”\nThe natural logarithm of the number 10 is: “<<log(10);
getch();
}
FUNCTIONS OF STDLIB.H HEADER FILE
The stdlib.h header file provides several general purpose functions for dynamic memory
management, random number generation, integer arithmetic, etc. Some of the functions of the
stdlib.h header file are:
Function Name Use Example Output
abs It returns absolute integral value. abs(-11) 11
abort It aborts the current process abort( ) Abort the current process.
abnormally.
div It returns integral division. div (38,5) 7 as quotient and 3 as remainder
exit It terminates the calling process. exit(0) Exit the program
Program 3: To use the functions of stdlib.h header file.
#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
int a;
cout<<”Enter a number: “;
cin>>a;
86 Touchpad MODULAR (Version 1.1)-X

