```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 ``` ```/* * Write a program to compute x^y based on using base-3 presentation of a number */ #include #include #include void base3function(int, int); int main() { int mybase=102, myexponent=2; // printf("Enter base number in Base-3 format: "); // scanf("%d", &mybase); // printf("Enter exponent number in Base-3 format: "); // scanf("%d", &myexponent); base3function(mybase, myexponent); printf("\n"); return 0; } void base3function(int base, int exponent) { int decimalbase, decimalexponent, i, result=1, remainder, quotient=1, num, val=1, numdigits=0; int base3result[50], base3finalresult[50]; printf("Base: %d Exponent: %d \n", base, exponent); /* Converting Base-3 numbers in Decimal */ num = base; while (num > 0) { remainder = num % 10; decimalbase = decimalbase + remainder * val; num = num / 10 ; val = val * 3; } printf("Decimal Base: %d\n", decimalbase); /* Converting Base-3 numbers in Decimal */ num = exponent; val=1; while (num > 0) { remainder = num % 10; decimalexponent = decimalexponent + remainder * val; num = num / 10 ; val = val * 3; } printf("Decimal Exponent: %d\n", decimalexponent); /* Calculate base^exponent */ for(i = 0; i < decimalexponent; i++){ result = result * decimalbase; } printf("%d^%d = %d\n", decimalbase, decimalexponent, result); /* Converting Decimal Result in Base-3 number */ for(i=0; quotient != 0; i++) { remainder = result%3; base3result[i] = remainder; quotient = result/3; result = quotient; printf("%d", base3result[i]); } numdigits = i-1; printf("\n%d^%d = ", base, exponent); for(i=0; numdigits>=0; i++) { base3finalresult[i] = base3result[numdigits]; numdigits--; printf("%d", base3finalresult[i]); } } ```
 ```1 2 3 4 5 6 ``` ```Base: 102 Exponent: 2 Decimal Base: -144089343 Decimal Exponent: -4111802 -144089343^-4111802 = 1 1 102^2 = 1 ```