removed pointer
This commit is contained in:
@@ -10,7 +10,7 @@ void main() {
|
|||||||
scanf("%i", &power);
|
scanf("%i", &power);
|
||||||
|
|
||||||
// calculate
|
// calculate
|
||||||
Calculate(&base, &power);
|
base = Calculate(base, power);
|
||||||
|
|
||||||
// output
|
// output
|
||||||
printf("\nThe number is: %i.", base);
|
printf("\nThe number is: %i.", base);
|
||||||
@@ -18,15 +18,13 @@ void main() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calculate(unsigned long* base, unsigned long* power) {
|
unsigned long Calculate(unsigned long base, unsigned long power) {
|
||||||
unsigned long baseOriginal = *base;
|
unsigned long baseOriginal = base;
|
||||||
if (*power == 0) { // power zero
|
if (power == 0) return 1; // power zero
|
||||||
*base = 1;
|
if (power > 0) { // power positive
|
||||||
return;
|
for (unsigned int i = 1; i < power; i++) {
|
||||||
}
|
base *= baseOriginal;
|
||||||
if (*power > 0) { // power positive
|
|
||||||
for (unsigned int i = 1; i < *power; i++) {
|
|
||||||
*base *= baseOriginal;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return base;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
//functions
|
//functions
|
||||||
void Calculate(unsigned long*, unsigned long*);
|
unsigned long Calculate(unsigned long, unsigned long);
|
||||||
|
|||||||
Reference in New Issue
Block a user