Thread: A little suggestion before positing your code

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489

    A little suggestion before positing your code

    Please format your code before posting! At least it contains good indentations.
    For example somebody(pssst...) posted this code:
    Code:
    #include <stdio.h>
    int main()
    {
    int x,ul,ll,j=1;
    
    printf("Please enter your desired number you want its divisible numbers\n");
    scanf("&#37;i",&x);
    
    
    printf("Please enter the lower limit you desire\n");
    scanf("%i",&ll); //ALERT: getchar(); --> its only with characters!
    
    printf("Please enter the upper limit you desire\n");
    scanf("%i",&ul);
    
    
    	for (j >= ll ; j <= ul; j--)
    	{
    		if (j < x)
    		{
    	if (j % x  == 0)
    			{
    				printf("\n%i", x);
    				j++;
    
    			}
    		}
    		else
    		{       if ( j == x)
    			{
    				j = 0;
    				printf("\t\t");
    			}
    		}
    	}
    
    	return (0);
    }
    ...it should be look like this:
    Code:
    #include <stdio.h>
    
    int main()
    {
       int x, ul, ll, j = 1;
    
       printf("Please enter your desired number you want its divisible numbers\n");
       scanf("%i", &x);
    
       printf("Please enter the lower limit you desire\n");
       scanf("%i", &ll); //ALERT: getchar(); --> its only with characters!
    
       printf("Please enter the upper limit you desire\n");
       scanf("%i", &ul);
    
       for(j>=ll; j<=ul; j--)
       {
          if(j < x)
          {
             if((j % x) == 0)
             {
                printf("\n%i", x);
                j++;
             }
          }
          else
          {
             if(j == x)
             {
                j = 0;
                printf("\t\t");
             }
          }
       }
    
       return(0);
    }
    Which is more readable?
    Please format your code before posting, because it make us easier to analyst your code and its algorithm.
    Last edited by audinue; 07-08-2008 at 05:11 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  2. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM