Hi,
i want to make a program of power by using function any one help me
example
2^2=4

Member Avatar for leegeorg07

maybe use

int i, pow;
printf("please enter the digit:\n");
scanf("%d", &i);
printf("\nThank you, and the power value?:\n");
scanf("%d", &pow);
printf("\nThe value is: %d", i**pow);

im not sure if it will work but its an idea?

printf("\nThe value is: %d", i**pow);

** is not an operator in C, it will be parsed as i * (*pow) , which should either not compile or throw a runtime exception because pow is not a pointer. The pow() function in math.h is the library way to calculate a power. It is also easy to write a loop that multiplies a number x times to get the power.

Member Avatar for leegeorg07

oh right, im just barely migrating from python, and it was the simplest method with it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.