c program using if function !!!!!!

This is a discussion on c program using if function !!!!!! within the C Programming forums, part of the General Programming Boards category; which is the shortest method to write a program to print 3 numbers in increasing order using if-else....... suppose we ...

  1. #1
    Registered User ravikanyal11's Avatar
    Join Date
    Oct 2011
    Location
    Dehradun, India, India
    Posts
    5

    Question c program using if function !!!!!!

    which is the shortest method to write a program to print 3 numbers in increasing order using if-else.......


    suppose we enter 4 5 6 and the output is 6 > 5 > 4 ;

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    That's nice homework - why not try it yourself first?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User ravikanyal11's Avatar
    Join Date
    Oct 2011
    Location
    Dehradun, India, India
    Posts
    5
    i tried so much but i can't . no need of full program but if u tell me some simple trick , use of operators , etc !!!!!!!!!!

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    Oh come on - surely you can write it for two numbers, even if the number of 'if' statements used isn't the minimum.

    What happens if we give you a 1-line piece of magic, then your tutor asks you to explain it to the rest of the class?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User ravikanyal11's Avatar
    Join Date
    Oct 2011
    Location
    Dehradun, India, India
    Posts
    5
    but program takes 2 or 3 pages......and it takes 9 something conditions... can u execute all condition in 2 or 3 steps

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,830
    There are only 6 possible outcomes - how can you possibly have 2 pages of code.

    Consider
    if ( a > b && a > c )
    How many permutations of b and c are left to resolve?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    2,768
    Test Cases; input to check program works right.
    1 2 3
    3 2 1
    1 3 2
    2 1 3
    2 3 1
    3 1 2
    2 2 2
    2 2 3
    2 2 1
    1 2 2
    3 2 2
    0 0 0

    Tim S.

  8. #8
    Registered User
    Join Date
    Mar 2009
    Posts
    344

  9. #9
    Registered User ravikanyal11's Avatar
    Join Date
    Oct 2011
    Location
    Dehradun, India, India
    Posts
    5
    yes 6 possibilities. it goes 2 pages coz of paper size
    my tutor ask me to solve this but i thnk its the shortest way to solve it


    Hey do u know name of a windows bug which used as a useful program in windows now a days
    Last edited by ravikanyal11; 10-24-2011 at 10:02 AM.

  10. #10
    Registered User ravikanyal11's Avatar
    Join Date
    Oct 2011
    Location
    Dehradun, India, India
    Posts
    5
    and more if we took 2 or 3 no. equal like stahta01 statement !


    I m newbie in c so any other way to solve it only with looping , switch case ,
    Last edited by ravikanyal11; 10-24-2011 at 10:11 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to call c++ function from c# program ?
    By gilit2 in forum C++ Programming
    Replies: 1
    Last Post: 02-06-2011, 11:49 AM
  2. Function Program
    By cutie0507 in forum C++ Programming
    Replies: 6
    Last Post: 11-24-2009, 11:38 PM
  3. Help please with function program.
    By gator6688 in forum C++ Programming
    Replies: 12
    Last Post: 10-01-2007, 12:40 PM
  4. function program help
    By katie2 in forum C++ Programming
    Replies: 4
    Last Post: 10-30-2006, 08:27 PM
  5. help with array & function program
    By Sway in forum C++ Programming
    Replies: 4
    Last Post: 09-29-2002, 08:30 PM

Tags for this Thread


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