I have the following code to just implement the pow()
as in math.h library.
Well I have two questions:
- Why the scanf() statement is taking input before
it prints
"power:"
from the printf() function? How can I calculate the power of big integers, like suppose the power calculated is like : 22235645654789787978797797 (just for example). How do I calculate and print it.
#include <stdio.h> unsigned long long int pow(unsigned long long int n,unsigned long long int d); int main(){ unsigned long long int a,x,n; printf("Number:"); scanf("%u\n",&a); printf("power:"); scanf("%u\n",&n); x = pow(n,a); printf("%u\n",x); } unsigned long long int pow(unsigned long long int n,unsigned long long int d){ if(n+1==1) return 1; return d*pow(n-1,d); }
In the image you can see the input of variable n
is taking input before printing "power:"
from printf(), so no matter what input do you type.
Please help me understand it. Open for any suggestions and comments.