howbcan i print A^2 means exp in c language
you can use the pow function in the header file math.h!!!
pow fxn can be used in this way…
also if you just want to print a^2…then print a*a…
but a way more faster method is exponential by squaring…for higher powers…
hope this helps…
There are two methods.
-
print pow(a,2). pow function can be found in math.h header file
printf("%d",pow(a,2));
-
print a*a.
printf("%d",a*a);
I Dont want to print the value i want to print the A power 2 whole itself on output screen not the value plz help me.
I Dont want to print the value i want to print the A power 2 whole itself on output screen not the value plz help me.
You can find power of a number using recursion in C program using this recursive equation.
getPower(A, n) = A X getPower(A, n-1);
2^3 = getPower(2,3) = 2 x getPower(2,2) = 2 x 2 x getPower(2,1) = 2 x 2 x 2 x getPower(2,0) = 2 x 2 x 2 x 1 = 8
Here is the full C program to find power of a number using loop and recursion.