help in c language

, ,

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…:slight_smile:

also if you just want to print a^2…then print a*a…:slight_smile:

but a way more faster method is exponential by squaring…for higher powers…:slight_smile:

hope this helps…:slight_smile:

There are two methods.

  1. print pow(a,2). pow function can be found in math.h header file

    printf("%d",pow(a,2));

  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.

you mean to say like this…E4u12s - Online C Compiler & Debugging Tool - Ideone.com …???

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.