Answer to Question #313806 in C for Suhani Goel

Question #313806

A man takes a job for 30 days. His pay for the first day is calculated as square

of his joining date. Assume he’s

joining on 3rd of the month, then his starting

pay is Rs 9/. After that his pay for the consecutive days are twice the pay of

previous day .i.e. each day’s pay is twice the pay of previous day. Write a c

program using functions to find his total pay for 3

0 days.



1
Expert's answer
2022-03-19T07:29:08-0400
#include <stdio.h>

int main()
{
    int day;
    double total;
    total = 0;        
    printf("Enter day of the month: ");
    scanf("%d", &day);
    total = total + (day * day);    // first day
    for (int i=0; i<29; i++)        // 2 .. 30 days
    {
        total = total * 2;
    }
    printf("\n\nTotal pay for 30 days (Rs): %.0f", total);
    getchar();  
}

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