1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Some consirns

  1. Apr 2, 2010 #1
    hello everyone
    i want your expert and your help plz
    i have to write a program that takes three numbers as input and write them in ascending order.
    Sample Program Run:
    Enter three numbers: 4 8 3
    Numbers in ascending order: 3 4 8
    how can i do it ?!:cry:
    and i want to ask you does the cmath knows the diffrence between even numbers and odd numbers ?!

    plz consider that am a very first level in c++ and i need your help :blushing::cry:


    thanks all
     
  2. jcsd
  3. Apr 2, 2010 #2

    Mark44

    Staff: Mentor

    Re: some concerns

    That's concerns...

    What have you tried to do? The rules of the forum say that you need to make an attempt at a solution before anyone can help you. See Homework Help here: https://www.physicsforums.com/showthread.php?t=5374.

    What's "the cmath?" How would it help to know whether the numbers are even or odd? That's not anything that's relevant in this problem.
     
    Last edited: Apr 2, 2010
  4. Apr 2, 2010 #3
    i'll check the link now :) !
    but abt the cmath its another question not realted to the first one :D!
     
  5. Apr 2, 2010 #4
    i haven't tried anything for honosty!
     
  6. Apr 2, 2010 #5

    Mark44

    Staff: Mentor

    cmath is the header math.h. You don't need any of the functions whose prototypes are in math.h if all you want to do is determine whether a number is even or odd. The modulo or remainder operator (%) is all you need. You don't need to include any headers to use it.

    This operator takes two operands, and returns the remainder when the first operand is divided by the second.
    For example 5 % 2 == 1, and 8 % 2 == 0.
     
  7. Apr 2, 2010 #6
    wt abt the acending thingy?!
     
  8. Apr 2, 2010 #7

    Mark44

    Staff: Mentor

    Take a stab at it and then show me what you've tried.
     
  9. Apr 2, 2010 #8
    #!perl
    print "Enter three numbers: ";
    print "Numbers in ascending order: ".join(" ",sort {$a <=> $b} (split /\D+/,<>))."\n";

    DaveE
     
  10. Apr 2, 2010 #9

    Mark44

    Staff: Mentor

    That's not going to be much help to the OP since he will be writing C++ code.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Some consirns
  1. Some Clarification (Replies: 27)

Loading...