Q:

Exponential function with addition

I am trying to create exponential function with for loop.  so if num1 is 10, and num2 is 2
for (i = 0; i < num1; i++)
      sum = sum + num2;
for (i = 0; i < num2 ; i++)
      sum2 = sum + sum2;

A:

Repeated addition mimics multiplication. 
Repeated multiplication mimics exponentiation. 
Just make two loops, one inside another: the inner loop to mimic multiplication and the outer loop to mimic exponentioation. 

EDIT: here's a recursive method.  Transforming it into a couple loops shouldn't be too difficult.  Tested on codepad. 
#include <stdio.h>

int mul(int b, int e) {
  if (e == 0) return 0;
  if (e == 1) return b;
  return b + mul(b, e - 1); /* additions only */
}

int expo(int b, int e) {
  if (e == 0) return 1;
  if (e == 1) return b;
  return mul(b, expo(b, e-1));
}

int main(void) {
  printf("3^0 is %d\n", expo(3, 0));
  printf("3^1 is %d\n", expo(3, 1));
  printf("3^2 is %d\n", expo(3, 2));
  printf("3^3 is %d\n", expo(3, 3));
  printf("3^4 is %d\n", expo(3, 4));
  return 0;
}

