Posted By

sebastianf on 02/01/10


Tagged

function power


Versions (?)

function power


 / Published in: C
 

  1. /* function power */
  2.  
  3. #include <stdio.h>
  4.  
  5. int main (int argc, const char * argv[]) {
  6. int i;
  7. for(i=0; i<10; i++)
  8. printf("2 hoch %i ist %i\n", i, power(2,i));
  9. }
  10.  
  11. int power(int x, int n){
  12. int i,p;
  13. p=1;
  14. for(i=1; i<=n; i++)
  15. p=p*x;
  16. return(p);
  17. }

Report this snippet  

You need to login to post a comment.