Hi all. I am fairly new to programming. I started with C since I was a EE student. I have a simple C program that needs to be improved by I don't know what else I could do.
Here's the code (I'm using VS C++ to compile)
Code:
#include "stdafx.h"
int salary = 0;
int fuel = 0;
double toll = 0;
int food = 0;
double balance = 0.00;
int calBalance(void);
int main()
{
int workDays = 0;
puts("My console in C to calculate my budget. Every component except salary takes DAILY use.\n");
printf("Working Days: ");
scanf("%d", &workDays);
printf("Salary: ");
scanf("%d", &salary);
printf("Fuel: ");
scanf("%d", &fuel);
fuel = fuel * workDays;
printf("Toll: ");
scanf("%lf", &toll);
toll = toll * workDays;
printf("Food: ");
scanf("%d", &food);
food = food * workDays;
calBalance();
printf("\nBalance: %.2f", balance);
puts("");
return 0;
}
int calBalance()
{
balance = salary - (fuel + toll + food);
return balance;
}
I think I don't need to explain the code since it is very straightforward. I feel like it can't be improved in the context of C(not C++).
Any suggestion?
Thanks.