Results 1 to 3 of 3

Thread: [RESOLVED] Small problem with computations

  1. #1

    Thread Starter
    Fanatic Member louvelle's Avatar
    Join Date
    Jun 2008
    Posts
    513

    Resolved [RESOLVED] Small problem with computations

    Code:
    	while (day1 != day2)
    	{
    		total = (result * 400) + total;
    		cout << total << endl;
    		day1++;
    	};
    it won't work... the output i -81231231299 something...

    Manny Pacquiao once posted in his twitter:
    It doesn't matter if the grammar is wrong, what matter is that you get the message

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Small problem with computations

    Some more explanation about your issue would be needed.



    Edit:

    Have you set total as 0 before entering the loop ? Otherwise if you have just declared the variable (without assigning 0 as value) and summed value to it, then it might give you unexpected values as output. Because the compiler would assign a garbage value for that variable, if you don't assign anything.

    Last edited by akhileshbc; Apr 16th, 2012 at 12:42 PM. Reason: "light bulb" - found another possibility of the reason for this issue :)

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3

    Thread Starter
    Fanatic Member louvelle's Avatar
    Join Date
    Jun 2008
    Posts
    513

    Re: Small problem with computations

    i found some syntax error in the upper part of my code.
    thanks for the reply..

    Manny Pacquiao once posted in his twitter:
    It doesn't matter if the grammar is wrong, what matter is that you get the message

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width