Questions tagged [math.h]

For questions relating to functions declared by the math.h header file of C programming language.

Most of the mathematical functions are placed in math.h header (cmath header in C++).
math.h header file has following functions:

int abs (int x);                    
long labs (long x);

double fabs (double x);
double sin (double x);
double cos (double x);
double tan (double x);
double asin (double x);
double acos (double x);
double atan (double x);
double sinh (double x);
double cosh (double x);
double tanh (double x);

double exp (double x);              ex
double log (double x);              ln x
double log10 (double x);            log x

double pow (double x,double y);     xy
double sqrt(double x);              square root of x
double fmod(double x, double y);    x mod y

double ceil (double x);
double floor(double x);
310 questions
-2
votes
2 answers

Error:identifier tgamma is undefined in c++ although is included

Im trying to use tgamma function in c++ 10.It's running on a 32-bit machine. I've included , but still getting the error "identifier tgamma is undefined ". what could be the reason?
NavidAmin
  • 3
  • 3
-2
votes
2 answers

Using pow(x,y) in large numbers

I am inputting a number n where 1<=n<=10^5. I need a number of length n. So I use pow(10,n-1) but it doesnt work when n=100000. What is the error ? EDIT: Its codeforces div2 round 152 problem B. Chilly Willy wants to find the minimum number of…
har777
  • 503
  • 5
  • 12
-3
votes
1 answer

i keep getting infinity as an output in my code

#include #include int i; double result = 0; int terms; int term; double stage1; double stage2; double zeta(int terms){ for (i=0; i != terms; i++){ result += 1 / pow(i, 2); } return result; } double pi(int…
-3
votes
2 answers

The output of ceil() and floor() in C language is odd

I am doing my homework to realize a C programe and during my work there is one step that I need to get the interger part of the double type numbers. So I choose ceil() or floor() in to realize this. But the output is unpredictable and far from…
sikisis
  • 458
  • 9
  • 21
-4
votes
2 answers

why pow function of math.h return infinity value?

I Want to Calculate x^y. x is -0.726354 and y is 0.954. So, I Using pow Function. but return infinity value. how to calculate when x value is negative. Please Answer to me. Thanks.
user1320165
  • 331
  • 1
  • 3
  • 8
-5
votes
1 answer

How to generate a horizontal sinusoidal text in C without graphics.h?

I am trying to write a program on generating a sinusoidal text in C. I tried the code below and got a vertical sine wave. Is it possible to make it horizontal? I am new to C programming, so if you could, please explain the code in simplest manner.…
-5
votes
1 answer

why does Pow function return unexpected values..?

#include #include #include using namespace std; int main() { int i; i = 2; printf("%d %d %d\n", i,pow(i,2),pow(i,3)); return 0; } /* I expect the output to be 2,4,8.But the output shown is 2 0…
-6
votes
2 answers

C++ console app with two colliding objects not Working

#include "stdafx.h" #include #include #include using namespace std; struct spaceship { // create the ship int x, y; char callsign[51]; }; void shiprandloc(spaceship *ship, int maxrange) { //randomize…
mahoward
  • 3
  • 2
-7
votes
2 answers

How do I calculate sin values in degree in c++?

I've been writing a code for a simple scientific calculator. Now, I've used math.h library but it gives the values of sin,cos,tan in radians while i want in degrees. I've tried using *180/PI but it isn't working. on the other hand, it's working…
Zain Abedin
  • 149
  • 9
-8
votes
2 answers

Doing C tutorials on the iMac, stuck on a challenge

I'm doing C programming on Xcode, Apple's IDE for the Mac and following the Big Nerd Ranch's guide to Objective C programming book. One of the challenge questions is to use the library in C to display the sine of 1 radian. I imported math.h and…
Keith Yong
  • 1,026
  • 1
  • 10
  • 18
1 2 3
20
21