Thread: Magic Box

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    21

    Magic Box

    hi

    i am trying to create the magic box of 3*3 using the random function

    here is my code.....
    Code:
    # include<stdio.h>
    # include<conio.h>
    main()
    {
      int i,a[9];
      for(i=1;i<=9;i++)
      {
      a[i]=rand();
      }
      while (true)
      {
    	if((a[0]+a[1]+a[2]==15)&&(a[3]+a[4]+a[5]==15)&&(a[6]+a[7]+a[8]==15)&&(a[0]+a[4]+a[8]==15))
    	{
    		for(i=0;i<9;i++)
    		{
    		printf("%d ",a[i]);
    		printf("\n");
    		}
    	}
    	else
    	continue;
    
      }
    }
    how to use the random function of c to put the values in the array?? and when i execute it says unidentified true symbol.....wat should i do???

    in case the condition is not satisfied then how should i continue so that it generates random again????
    thanks
    Last edited by Salem; 08-18-2007 at 11:43 AM. Reason: Code tags go AROUND the code, don't just put them anywhere to make the popup go away

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Virtual Box
    By ssharish2005 in forum Tech Board
    Replies: 3
    Last Post: 02-12-2009, 05:08 AM
  2. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  3. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 08:34 PM
  4. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM