424,952 Members | 943 Online Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

need help... it keep warn me bout possible use and never used..

 P: 1 Expand|Select|Wrap|Line Numbers #include #include   void intro (); void input(int& , int& ); float calculate1 ( int ); float calculate2 (int , int ); float calculate3 (int , int  ); float calculate4 (int , int ); void close (int , int , int ) ;   int main() {     int finance, month, totalMoney, totalMoneyMonth, spendMoney, useMonth, useDay, totalSave ;     intro ();    input ( finance, month);    calculate1 ( month);    calculate2 ( totalMoneyMonth,  finance );    calculate3 ( totalMoney, totalSave);    calculate4 ( month, spendMoney);    close ( totalSave,  useMonth,  useDay);   getch (); return 0; }   void intro ()                                                                   //greeting the user {     cout<<"Hello there! Want to save money and help yourself to minimize money loss?"<>finance;    cout<<"Enter how much month you want to be calculated : ";    cin>>month;   }   float calculate1 ( int month)    //finding the total saving and total money {     float totalMoneyMonth = 0, count = 1, pocket, totalSave = 0,save;           while (count <= month);       {           cout<<" Enter the amount of money you receive in the "<>pocket;          cout<<"How much money you want to save this month? : ";          cin>>save;          totalSave = totalSave + save;           totalMoneyMonth = totalMoneyMonth + pocket;          count++;       } return totalSave, totalMoneyMonth; }     float calculate2 (int totalMoneyMonth, int finance )      //finding the total money the user have {     float totalMoney;     totalMoney = totalMoneyMonth + finance; return totalMoney; }       float calculate3 (int totalMoney, int totalSave)          //finding the total money the user can use {     float spendMoney =0 ;     spendMoney = totalMoney - totalSave;   return spendMoney; }       float calculate4 (int month, int spendMoney)        //finding the total money the user can use {     int days = 180, useDay, useMonth;     useMonth = spendMoney / month;    useDay = spendMoney / days; return useDay, useMonth; } void close (int totalSave, int useMonth, int useDay)                       //tell the user about the result {     cout<<"The money you can save for this semester is : "<
3 Replies

 Expert Mod 5K+ P: 9,197 None of your variables are initialized before you use them. That means you can't trust your results. Initialize all your float variables to 0.0 and all of your int variables to 0 before you use any of them. Mar 10 '17 #2

 P: 62 Here are the few things I noticed: 1: On line 37, change 'char &month' to 'int &month'. 2: On line 60 and 88, the functions are trying to return more than one values. A function can return only one value. [ left operand of comma operator has no effect [-Wunused-value] ] 3: As mentioned by @weaknessforcats, initialise the variables. Also, try to mention some theoretical concept of the program as by that it would be easy for others to analyse the program well. Mar 12 '17 #3

 P: 62 Here are the few things I noticed: 1: On line 37, change 'char &month' to 'int &month'. 2: On line 60 and 88, the functions are trying to return more than one values. A function can return only one value. [ left operand of comma operator has no effect [-Wunused-value] ] 3: As mentioned by @weaknessforcats, initialise the variables. Also, try to mention some theoretical concept of the program as by that, it would be easy for others to analyse the program well. Mar 12 '17 #4 