# Beginner need help with code

 Горан Куга · October 12, 2014 Hi guys. My name is Goran and i'm a beginner in C Programming. So i was thinking to write a code that will ask you for your daily income and will show you how much you will earn every next day. One example so you will know what i'm talking about. So if your daily income is \$2000 on Day 4 you will earn \$8000. I done almost everything but i don't know how to set up earnByDay to sum with earnByDay.Day: 1 Cash Earned: 2000Day: 2 Cash Earned: 4000Day: 3 Cash Earned: 6000Day: 4 Cash Earned: 8000``#include #include #include #include #include /*How much do you earn per day calculator by Goran*/int main(){ float earnPerDay, day = 0; printf("How much do you earn per day? "); scanf(" %f", &earnPerDay); printf("\n"); do{ printf("Day: %.0f Cash Earned: %.0f \n", day, earnings); day++; }while(day <= 31); printf("\n"); system("pause"); return 0;}``

## Replies

 Marcus Sinclair · October 12, 2014 Thanks for the info. Glad I could help. Горан Куга · October 12, 2014 Thanks for your reply i will take a look at your way of doing it. You press code button when you are replying and there you put your code. I need someone to tell me is it possible to do it on my way ? Горан Куга · October 12, 2014 After looking at your example i managed to get mine working. If anyone is interesed here is the code. I also provide same code but with comments  http://pastebin.com/hMQVz6Cb.``#include #include #include #include #include /*How much do you earn per day calculator by Goran*/int main(){ float earnPerDay, day = 0, earnings = earnPerDay; printf("How much do you earn per day? "); scanf(" %f", &earnPerDay); printf("\n"); do{ printf("Day: %.0f Cash Earned: %.0f \n", day, earnings); day++; earnings += earnPerDay; }while(day <= 31); printf("\n"); system("pause"); return 0;}`` Marcus Sinclair · October 12, 2014 Hi,Here's how I would do it.#include #include int main(){    float earnbyday;    printf("How much do you earn a day?\n\$");    scanf(" %f",&earnbyday);    int i;    int maxday=31;    float earnings= earnbyday;    for (i=1; i<=maxday; i++)    {        printf("You earned \$%.2f on day %d\n",earnings,i);        earnings +=earnbyday;    }    return 0;}  BTW How do you post replies set up the way you did to show the layout better? (ie the black bg coloured tags etc)
• 1

## C

120,898 followers