Okay so I am programming and my tutor told me to fix my program about exponents and computing exponents. My program will only tell the answers when the exponent is 0 or greater than one. Whenever I enter 1 as my exponent it will tell me the answer to the equation is 1 instead of the base number. I was wondering if someone could help me with this. Here is my code:
insertNow I don't know what is wrong with this but if someone could help me that would be great!Code:#include <stdio.h> #include "genlib.h" #include "simpio.h" /* This program computes the power of a number */ main() { int base,exponent,counter,i; printf("This program computes the power of a number using multiplication.\n"); printf("Enter your base number:"); base = GetInteger(); counter = base; printf("Enter your exponent:"); i = 0; exponent = GetInteger(); if(exponent>1) { while(i<exponent){ base = base*counter; i = i + 2; } } else if (exponent>=0){ base = 1; } else if (exponent >= 1) { base = counter; } else { printf("There is a bug in this program."); } printf("%d to the power of %d is:%d.",counter,exponent,base); }