Wednesday, 26 April 2017

mathematical functions in c

// 1.
        #include <stdio.h>
        #include <math.h>
        void main()
        {
            int k = pow(2, 4);
            printf("%d\n", k);
        }

// This program outputs 2 power 4 as 16

//2.

        #include <stdio.h>
        #include <math.h>
        void main()
        {
            int k = fabs(-57);
            printf("%d\n", k);
        }
// This program outputs -57 absolute value as 57


//3.

        #include <stdio.h>
        #include <math.h>
       
        void main()
        {
        int k = sqrt(100);
        clrscr();
        printf("%d\n", k);
        getch();
        }
// This program outputs 100 square root 10 as result

//4.

        #include <stdio.h>
        #include <math.h>
        int main()
        {
            int i = 90;
            printf("%f\n", sin(i));
            return 0;
        }
// caliculates sin90 function


//5. log caliculation

        #include <stdio.h>
        #include <math.h>
        int main()
        {
            int i = 10;
            printf("%f\n", log10(i));
            return 0;
        }

No comments:

Post a Comment