Answer to Question #114952 in C for EDDIE

Question #114952
A child's parents promised to give the child $10 on her 12th birthday and double the gift on every subsequent birthday until the annual gift exceeded $1000. Write a C program to determine how old the child will be when the last amount is given and the total amount the child will have received.
1
Expert's answer
2020-05-11T12:45:02-0400
#include <stdio.h>

int main() {
    int year = 12, value = 10, total = 0;
    do {
        year++;
        value *= 2;
        total += value;
    } while (value < 1000);

    printf("Age: %d", year);
    printf("\nLast gift: %d", value);
    printf("\nTotal: %d",total);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS