Assignment: Print reverse order

Discussion in 'C Programming' started by aatish19@gmail.com, Apr 12, 2006.

  1. Guest

    1: Write a program that asks the user to input an integer value and
    print it in a reverse order
    Sample Output
    Enter any number 65564
    Reverse of 65564 is 46556

    2: Write a program that takes a string as an input and print it in
    reverse order.(don't use bulit-in/library function).
    Sample Output
    Enter any string: i m Kashif
    Reverse of
    i m kashif
    is
    fihsak m i
     
    , Apr 12, 2006
    #1
    1. Advertising

  2. Re: Assignment: Print reverse order

    wrote:
    > 1: Write a program that asks the user to input an integer value and
    > print it in a reverse order
    > Sample Output
    > Enter any number 65564
    > Reverse of 65564 is 46556
    >
    > 2: Write a program that takes a string as an input and print it in
    > reverse order.(don't use bulit-in/library function).
    > Sample Output
    > Enter any string: i m Kashif
    > Reverse of
    > i m kashif
    > is
    > fihsak m i


    So what's your question?

    Robert Gamble
     
    Robert Gamble, Apr 12, 2006
    #2
    1. Advertising

  3. "" <> writes:
    > 1: Write a program that asks the user to input an integer value and
    > print it in a reverse order
    > Sample Output
    > Enter any number 65564
    > Reverse of 65564 is 46556


    Done.

    > 2: Write a program that takes a string as an input and print it in
    > reverse order.(don't use bulit-in/library function).
    > Sample Output
    > Enter any string: i m Kashif
    > Reverse of
    > i m kashif
    > is
    > fihsak m i


    Done.

    I'm not sure why you wanted me to write those programs, but I had fun
    writing them. Thanks.

    (Perhaps you were looking for comp.lang.c.do.my.homework.for.me?)

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Apr 12, 2006
    #3
  4. osmium Guest

    <> wrote:

    > 1: Write a program that asks the user to input an integer value and
    > print it in a reverse order
    > Sample Output
    > Enter any number 65564
    > Reverse of 65564 is 46556
    >
    > 2: Write a program that takes a string as an input and print it in
    > reverse order.(don't use bulit-in/library function).
    > Sample Output
    > Enter any string: i m Kashif
    > Reverse of
    > i m kashif
    > is
    > fihsak m i


    You have posted three problems you have been assigned. The second problem
    above is the easiest and clearest. Focus on that one instead of flailing
    around. Do you know how to read a string into memory? If not, concentrate
    on that first.

    The comment about clarity relates to problem 1 above. A user has no idea of
    what an integer is unless you tell him. Is 123456789123456789 an integer?
    Unless you tell me otherwise it is, indeed, an integer. Note that one can
    read question 2 to have the same meaning, with a different datum as question
    1.
     
    osmium, Apr 12, 2006
    #4
  5. Flash Gordon Guest

    wrote:
    > 1: Write a program that asks the user to input an integer value and
    > print it in a reverse order
    > Sample Output
    > Enter any number 65564
    > Reverse of 65564 is 46556


    #include <stdio.h>
    int main(void)
    {
    puts("Please input an integer value and print it in a reverse order\n"
    "Sample Output\n"
    "Entry any number 65564\n"
    "Reverse of 65564 is 46556");
    return 0;
    }

    OK, that's done. The above asks the user to input a value and print it
    as requested. It might be more helpful if it told the user where to
    input the value and where to print it, but that was not in the
    specification.

    > 2: Write a program that takes a string as an input and print it in
    > reverse order.(don't use bulit-in/library function).
    > Sample Output
    > Enter any string: i m Kashif
    > Reverse of
    > i m kashif
    > is
    > fihsak m i


    You can't write a program to take inpput from a user and produce output
    without using library functions (even getc/putc might use library
    functions).

    If you want code written for you then my current out of hours rate is
    500UKP per hour or part there of with a minimum charge of 5000UKP. To
    get the work done in my normal working hours you will have to contact my
    employer, however I'm already booked up till well in to next year so
    that would probably not do you.

    In other words, if you don't even try to do your homework why should we
    do it for you? I certainly don't want people passing courses on that
    basis since I might have to deal with their inability to program if they
    get a job later!
    --
    Flash Gordon, living in interesting times.
    Web site - http://home.flash-gordon.me.uk/
    comp.lang.c posting guidelines and intro:
    http://clc-wiki.net/wiki/Intro_to_clc
     
    Flash Gordon, Apr 12, 2006
    #5
  6. ed Guest

    On 12 Apr 2006 08:53:11 -0700
    "" <> wrote:

    > 1: Write a program that asks the user to input an integer value and
    > print it in a reverse order
    > Sample Output
    > Enter any number 65564
    > Reverse of 65564 is 46556


    #include <stdio.h>

    int main() {
    print( "it in a reverse order\n" );
    return(0);
    }

    >
    > 2: Write a program that takes a string as an input and print it in
    > reverse order.(don't use bulit-in/library function).
    > Sample Output
    > Enter any string: i m Kashif
    > Reverse of
    > i m kashif
    > is
    > fihsak m i


    See answer to q1.

    Sorry if you feel I am being pedantic. Please don't just post your home
    work questions, at least have a go, send your attempt along with the
    question and any errors which you are getting.

    --
    Regards, Ed :: http://www.s5h.net
    :%s/\t/ /g :: proud unix system person
    :%s/Open Source/Free Software/g
     
    ed, Apr 12, 2006
    #6
  7. wrote:
    > 1: Write a program that asks the user to input an integer value and
    > print it in a reverse order
    > Sample Output
    > Enter any number 65564
    > Reverse of 65564 is 46556


    Is this trivial or what?
    Trivial approach 1: Look up the '%' and '/' operators for integer values.
    Trivial approach 2: Since your assignment does not require you to read
    the interger as an integer, just fgets() the string and print it out
    backwards.

    > 2: Write a program that takes a string as an input and print it in
    > reverse order.(don't use bulit-in/library function).


    All I/O for C programs uses streams and library functions. Your
    assignment is impossible.
     
    Martin Ambuhl, Apr 12, 2006
    #7
  8. Keith Thompson wrote:
    > "" <> writes:


    >>2: Write a program that takes a string as an input and print it in
    >>reverse order.(don't use bulit-in/library function).
    >>Sample Output
    >>Enter any string: i m Kashif
    >>Reverse of
    >>i m kashif
    >>is
    >>fihsak m i

    >
    >
    > Done.


    I don't believe you.
     
    Martin Ambuhl, Apr 12, 2006
    #8
  9. Martin Ambuhl <> writes:
    > Keith Thompson wrote:
    >> "" <> writes:

    >
    >>>2: Write a program that takes a string as an input and print it in
    >>>reverse order.(don't use bulit-in/library function).
    >>>Sample Output
    >>>Enter any string: i m Kashif
    >>> Reverse of i m kashif is fihsak m i

    >> Done.

    >
    > I don't believe you.


    Ok, I glossed over the "don't use bulit-in/library function" requirement.

    I avoided using any library functions in the reversal code.
    I did use library functions for I/O.

    I also ignored the discrepancy between "Kashif" and "kashif", assuming
    it to be a typo.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Apr 12, 2006
    #9
  10. "Keith Thompson" <> wrote in message
    news:...
    > Martin Ambuhl <> writes:
    > > Keith Thompson wrote:
    > >> "" <> writes:

    > >
    > >>>2: Write a program that takes a string as an input and print it in
    > >>>reverse order.(don't use bulit-in/library function).
    > >>>Sample Output
    > >>>Enter any string: i m Kashif
    > >>> Reverse of i m kashif is fihsak m i
    > >> Done.

    > >
    > > I don't believe you.

    >
    > Ok, I glossed over the "don't use bulit-in/library function" requirement.
    >
    > I avoided using any library functions in the reversal code.
    > I did use library functions for I/O.
    >
    > I also ignored the discrepancy between "Kashif" and "kashif", assuming
    > it to be a typo.
    >


    What? Your wasting your time on this, when you could be ripping my FUBAR'd
    realloc() to shreds? "Spec. kiddy" (yes, that's a bad play on "script
    kiddy") you're losing it. If you were ripping my realloc(), you still
    wouldn't have to post any code...at all...like usual...


    Rod Pemberton
     
    Rod Pemberton, Apr 13, 2006
    #10
  11. "" wrote:
    >
    > 1: Write a program that asks the user to input an integer value and
    > print it in a reverse order
    > Sample Output
    > Enter any number 65564
    > Reverse of 65564 is 46556
    >
    > 2: Write a program that takes a string as an input and print it in
    > reverse order.(don't use bulit-in/library function).
    > Sample Output
    > Enter any string: i m Kashif
    > Reverse of
    > i m kashif
    > is
    > fihsak m i


    on
    )yawdaorB revO stelluB ni sa tellub tub tilub ton s'ti .wtb(
     
    Wolfgang Riedel, Apr 13, 2006
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shannon Yoder

    How do I list records in reverse order?

    Shannon Yoder, Aug 14, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    393
  2. dogbite
    Replies:
    4
    Views:
    694
    osmium
    Oct 10, 2003
  3. vijay
    Replies:
    8
    Views:
    715
  4. keto
    Replies:
    0
    Views:
    964
  5. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    363
    David Cournapeau
    Dec 30, 2008
Loading...

Share This Page