========================================
CODE 1
========================================
#include <stdio.h>
int power(int, int);
int main() {
int total, number_of_days;
//initialize the value
number_of_days = 10;
total = power(2, number_of_days); //total = 2 to the power of 10; value ng number_of_days
//print the result
printf("\nWages on Day %d is %d.", number_of_days, total / 2);
printf("\nThe total amount received from Day 1 to Day %d is %d.", number_of_days, total - 1);
return 0; //terminate the program
} //end main
//recursive function
int power(int x, int y) {
if(y == 1)
return x;
return x * power(x, y - 1);
}
========================================
CODE 2:
========================================
#include <stdio.h>
int main() {
int i, j, total, number_of_days;
//initialize the value
number_of_days = 10;
total = 1;
i = 1;
j = 0;
while(i != number_of_days) {
do {
j++;
total = total * 2;
} while(i == j); //end do-while
i++;
} //end while
//print the result
printf("\nWages on Day %d is %d.", number_of_days, total / 2);
printf("\nThe total amount received from Day 1 to Day %d is %d.", number_of_days, total - 1);
return 0; //terminate the program
} //end main