Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- //define how ^ should work for computer
- int power(int base,int power){
- int i;
- for(i=0;i<power;i++)
- {
- base*=base;
- }
- return base;
- }
- int main(){
- //set initial values to 0
- int baseA=0;
- int powerA=0;
- int baseB=0;
- int powerB=0;
- printf("Enter baseA and powerA\n");
- scanf("%d %d", &baseA, &powerA);
- while(1)
- {
- printf("Enter baseB and powerB\n");
- scanf("%d %d", &baseB, &powerB);
- //check if numbers are equal then break out of loop
- if(power(baseA,powerA)==power(baseB,powerB))
- break;
- printf("Not equal.\n");
- }
- printf("%d^%d = %d^%d = %d", baseA, powerA, baseB, powerB, power(baseA,powerA));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement