Results 1 to 2 of 2
  1. #1
    egrizzly is offline Member
    Join Date
    Jun 2016
    Posts
    10
    Rep Power
    0

    Default Simple pre-decrement question baffles me.

    hmm, in the code below its showing that m is zero when I run it. I calculated m to be 12. Got a test coming up this evening. Is there something I'm missing? I'm referring to the line m /= --c * --d;


    Java Code:
    import java.util.Scanner;
    class test2
    {
    	public static void main(String[] args)
    	{
    		Scanner input = new Scanner(System.in);
    		int a = 2; 
    		int b = 3; 
    		int c = 4; 
    		int d = 5;
    		int m = 10;
    		boolean n=false;
    		
    		// m %= ++a * b++;
    	   // m *= a++ + b++;
    		m /= --c * --d;
    		// m = += c-- + --d;
    		System.out.println(m);
    
    
    	}
    }
    Last edited by egrizzly; 06-29-2016 at 07:50 PM. Reason: additional clarification

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Simple pre-decrement question baffles me.

    I calculated m to be 12.
    Can you post your calculations so we can see what you did?
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. increment and decrement concept in java
    By bhavneetkaur in forum OCPJP
    Replies: 2
    Last Post: 12-02-2012, 04:18 PM
  2. Simple question
    By Games2Design in forum New To Java
    Replies: 10
    Last Post: 09-30-2012, 07:54 PM
  3. A simple question
    By Rylogy in forum AWT / Swing
    Replies: 2
    Last Post: 02-15-2012, 01:54 AM
  4. Simple question
    By Qsc in forum New To Java
    Replies: 6
    Last Post: 03-06-2011, 11:24 PM
  5. Probably a really simple question...
    By ibanez270dx in forum New To Java
    Replies: 0
    Last Post: 11-16-2007, 01:27 AM

Posting Permissions

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