W e b t u t o r i a l s

Programing Approach

Algorithm, Flow Chart

Define C

Define Programming

C - Syntax

C - Variables

C - Keywords

C - Data Types

C - Comments

Turbo C - Shortcut keys

C - Operators

Hierarchy of Operators

Ex: Arithmetic Operator

Control Structure

Control Structure - if

Ex: If condition

Ex: Inc / Dec Operator

C - loops

Ex: Loops

C - Nesting Of loops

Ex: Nested Loops

Constant Variable

C - Escape Sequence

C - Arrays 1D, 2D

C - Sorting

ASCII Value

Character I/O Function

C - Strings

Ex: Strings

Array of Strings

C - Math Functions

C - Functions

C - Types of Functions

Storage Class

C - Header Files

C - Preprocessor

C - Pointers

C - Structures

Typedef File Handling

Command Line Argument

MCQ

Math Library Functions

The math.h header file defines various mathematical functions that can be used in our program. Common 'C - Language' Math functions are:

S.no Functions Syntax Description
1 abs() abs(value); abs() Stands for absolute value. It Returns the absolute value of a integer number means it convert negative value into positive value.
2 fabs() fabs(float value); Return the absolute value of a float number.
3 ceil() ceil(decimal value); Remove the decimal places and return the integer number. It returns one value greater to the original number.
4 floor() floor(decimal value); Remove the decimal places and return the integer number. It returns one value smaller to the original number.
5 fmod() fmod (x, y); Divide two float numbers and return the reminder.
6 modf() double a, b;
double c=modf(a,b);
Splits the double number into number and its decimal value.
Note: a,b,c should be in double.
7 pow() c = pow (a, b); Calculate a power b.
Note: a and b can be int, long, float, double.
8 sqrt() s=sqrt(n); Calculate the square root of a number.
Number can be int, long, float, double.
9 sin() sin (value); Calculate the sin value in radians.
Value should be in decimal.
10 cos() cos (value); Calculate the cos value in radians.
Value should be in decimal.
11 tan() tan (value); Calculate the tan value in radians.
Value should be in decimal.
                Note: degree = radian * (180 / pi);
           
Example: Math abs() Function
void main()
{
  int a;
  printf("Enter number");
  scanf("%d",&a);
  printf("Absolute value = %d",a);
  getch();
}
Example: Math fabs() Function
void main()
{
  double a;
  printf("Enter number");
  scanf("%lf",&a);
  printf("Absolute value = %lf",a);
  getch();
}