Try this... #include <iostream> #include <cmath>
using namespace std; #define DIGITS 10001 void mult(int N,int pro[],int &len) { int carry = 0; for(int i=0;i<len;i++) { int temp = pro[i]*N + carry; pro[i] = temp%10; carry = temp/10; } if(carry>0) { pro[len] = carry; len++; } } int main() { int t,N,E; scanf("%d",&t); while(t--) { int pro[DIGITS]; scanf("%d %d",&N,&E); if(N==1) { printf("1 1\n"); continue; } pro[0] = 1; int len = 1; for(int i=0;i<E;i++) { mult(N,pro,len); } for(int i=len-1;i>=0;i--) { printf("%d",pro[i]); } printf("\n"); } return 0; } Here t stands for number of testcases... N => the number for which power is to be calculated.. E => the exponent.. On Thu, Mar 24, 2011 at 12:22 PM, bittu <shashank7andr...@gmail.com> wrote: > How you will print the 100th power of a single digit( which is of type > int). How do you maintain that big number in memory? > > > Lets C The Approach > > Thank & Regards > Shashank > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.