I was wondering if I can help me with this c program. I have tomake a program th
ID: 3613308 • Letter: I
Question
I was wondering if I can help me with this c program. I have tomake a program that implements the pow function using nomultiplication. The way I am trying to do it is by using repetitiveaddition. This is what I have so far:#include <stdio.h>
int main(void)
{
int base;
int power;
int i;
int j;
int temp = 0;
int answer = 0;
printf("Please Enter Base and Power: ");
scanf("%d%d",&base,&power);
temp = base;
if(power == 0)
{
printf("Answer: 1 ");
return;
}
for(i=1; i<power;i++)
{
temp = 0;
for(j = 1; j<base;j++)
{
temp = temp + base;
}
answer = answer + temp;
}
temp = answer;
printf("Answer: %d ", temp);
return(0);
}
I dont know what I am doing wrong. If you can help me I wouldgreatly appreciate it. I will rate. Thank You for your time.
Explanation / Answer
please rate - thanks #include #include int main(void) { int base; int power; int i; int j; int k; int temp = 0; int answer =0 ; printf("Please Enter Base and Power: "); scanf("%d%d",&base,&power); temp = base; if(power == 0) { printf("Answer: 1 "); return 0; } for(i=1; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.