Simple fix.

This is a discussion on Simple fix. within the C Programming forums, part of the General Programming Boards category; Hi, I want to perform the following algorithm but dont know where to place brackets and semicolons. Can someone show ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    1

    Simple fix.

    Hi, I want to perform the following algorithm but dont know where to place brackets and semicolons. Can someone show mw plz.

    Code:
    if ( i > 20 )
    if ( i == 10 )
    printf( “Here I am...” );

  2. #2
    Registered User
    Join Date
    Mar 2008
    Posts
    43
    Quote Originally Posted by greg_yia View Post
    Hi, I want to perform the following algorithm but dont know where to place brackets and semicolons. Can someone show mw plz.

    Code:
    if ( i > 20 )
    if ( i == 10 )
    printf( “Here I am...” );

    The example did not really make sense but heres a few guesses...

    Code:
    #include <stdio.h>
    
    int main()
    {
    	int i;
    	
    	for(i = 0; i < 30; i++)
    	{
    		if(i > 20)
    		{
    			printf("i > 20 and equals %d\n", i);
    		}
    		if(i == 10)
    			printf("i == 10\n");
    	}
    
    	return 0;
    }
    
    }
    you don't always need the braces.

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    maybe you want
    Code:
    if(i>20 || i == 10)
       puts("Here I am");
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ code need help to fix
    By McReal in forum C++ Programming
    Replies: 9
    Last Post: 05-12-2007, 03:48 PM
  2. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM
  3. ...deceptively simple...
    By Sebastiani in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 07-29-2002, 01:51 PM
  4. Need help with simple DAQ program
    By canada-paul in forum C++ Programming
    Replies: 12
    Last Post: 03-15-2002, 08:52 AM
  5. The following code has one simple error.....
    By bluehead in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 11-08-2001, 07:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21