C Programming Tutorial - 10: The pow() Function

preview_player
Показать описание
In this tutorial we'll learn to use the pow() function to perform the exponentiation operation i.e to compute the result of a number raised to the power of another number.

Thanks for watching!
Рекомендации по теме
Комментарии
Автор

finally a straight forward and simple video for beginners like me.

inferno
Автор

Thnx a lot
You illustrated it in a simple way

amirhosseinhami
Автор

Good explanation!
You know, math.pow() takes double's in the argument double(double, double); so using an int here would take slightly longer as the compiler would have to cast the int to a double. It would add micro seconds to compile time, though having many many lines of code using pow with an int would not be the most efficient way to do it. I'd would do pow(5.0, 3.0); || pow(5., 3.);

philgolden
Автор

how can i write this pow function code? That is ====> pow(double x, double y) function. For exp: That pow function will calculate (5.5)^(2.7)?

alperendagistan
Автор

Excellent. My tutorials were usually far to complex. Like how to program a wavetable synthesizer or a vocoder with complex imaginary numbers.

GaryKildall
Автор

thank you...for your clear and useful instruction's..please keep up the good work

Iztiak
Автор

Hi...first of all tuts are very good...encouraging to learn C progg..I tried this pow() function program by accepting user inputs..but result shown is not correct..like 5 raised to 2 is 24!!...Where have I gone wrong?

#include<stdio.h>
#include<math.h>

main()
{
    int x, y, z;
    printf("Enter any integer:");
    scanf("%d", &x);
    printf("\nEnter the power to which above integer is to be raised:");
    scanf("%d", &y);

    z=pow(x, y);
    printf("%d raised to %d is: %d", x, y, z);
}

ashutoshtambe
Автор

#include <stdio.h>
#include <math.h>

int main()
{
  int  base, power, result;



  printf("Enter base:\n");
  scanf("%d", &base);

  printf("Enter exponent:\n");
  scanf("%d", &power);

  result= pow(base, power);

  printf("%d ^ %d= %d\n", base, power, result);

  return 0;
   
 }

everytime when i do 5 ^2 it gives 24 .I dont know what is going on in this program.Please give me a solution to this problem/...

sabinshrestha
Автор

Write a program in FORTRAN that ask the user to enter a value of x then calculate the function y where :
y=sin(x)+2x When x>4
y=cos(x)-6x When x<4
y=exp(x)+tan(x) When x=4


لوز-ذض
Автор

great tutoruials! Although I should have spend more time to math in high school :P

cllarzmbi
Автор

thanks i was making calculator and this pow function pissess me thanks but you solved my prob

TheCreatorsmalik
Автор

Это весь разбор функции?
А синтаксис - double pow() - 64, float powf -32, long double powl - 80 .
Как применять функцию pow с выражениями типа (x + y) .
Informational - 0 !

ИсламГашимов-эн
Автор

Am i need to use the option -lm on gcc? And why? 

andersonsilva
Автор

doesn't work for bigger values like
100 power 10. it shows a max. no. 2147483647
why this???

tejeshwarreddy
Автор

sorry, but what is the symbol in the parenthesis on the printf line?

yazid
Автор

Please tell me what is wrong#include <stdio.h>
#include <math.h>
main ()
{
    int x, y, z;
    printf("Enter number");
    scanf("%d", &y);
    printf("\nEnter power:");
    scanf("%d", &z);
    x=pow(y, z);
    printf ("\nThe answer is %d", x);
}If I do this most results are correct, but 5^2 results in 2425^2 results in 62410^2 results in 99100^2 results in 9999and so on

ujwalnayak