Results 1 to 4 of 4
  1. #1
    vknehra10 is offline Member
    Join Date
    Dec 2016
    Posts
    37
    Rep Power
    0

    Post What's mistake in IF logic..

    hey i want to print this pattern (PYRAMID)

    What's mistake in IF logic..-2.jpg


    but the output is showing like this

    What's mistake in IF logic..-1.jpg

    Java Code:
    import java.util.Scanner;
    public class Exr{
    public static void main(String dev[])
    {
    	for(int j=1;j<=5;j++)
    	{
    	for(int i=1;i<=5;i++)
    	{
    		if(i>=6-j && i<=4+j)
    		System.out.print("*");
        else    
             System.out.print(" ");	
    	}
    	   System.out.println(" ");
    	}
    }
    }
    Last edited by Norm; 01-09-2017 at 03:04 PM. Reason: \ changed to / in ending code tag

  2. #2
    SurfMan's Avatar
    SurfMan is online now Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,722
    Rep Power
    6

    Default Re: What's mistake in IF logic..

    The inner loop (i) should run 2*5.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    vknehra10 is offline Member
    Join Date
    Dec 2016
    Posts
    37
    Rep Power
    0

    Default Re: What's mistake in IF logic..

    can you please do it for me

    Thanks..

  4. #4
    vknehra10 is offline Member
    Join Date
    Dec 2016
    Posts
    37
    Rep Power
    0

    Default Re: What's mistake in IF logic..

    Quote Originally Posted by SurfMan View Post
    The inner loop (i) should run 2*5.
    i got it thanks...

Similar Threads

  1. What is my mistake!!?!
    By Hendy in forum New To Java
    Replies: 2
    Last Post: 11-29-2016, 03:34 AM
  2. can anyone tell me my mistake please?
    By metallica in forum New To Java
    Replies: 3
    Last Post: 01-31-2014, 09:08 PM
  3. Hello, I got a mistake
    By F1ke in forum New To Java
    Replies: 7
    Last Post: 09-25-2011, 08:11 PM
  4. i can't see the mistake
    By PVL268 in forum New To Java
    Replies: 3
    Last Post: 04-29-2009, 05:26 AM
  5. i can't see the mistake
    By PVL268 in forum New To Java
    Replies: 2
    Last Post: 04-28-2009, 06:30 AM

Tags for this Thread

Posting Permissions

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