hi can give me idea

Discussion in 'C++' started by Jerry Coffin, Sep 18, 2007.

  1. Jerry Coffin

    Jerry Coffin Guest

    In article <>,
    says...
    > hem anyone can give me an idea on how to saparated digits using
    > looping
    >
    > example
    >
    > please key in any 5 digits number : 56789
    >
    > and the ouput is
    > 5678 9
    > 5678 9
    > 567 89
    > 56 789
    > 5 6789
    >
    > huhu how to saparate those digin huhuhu can help???anyone?


    Perhaps the observation that:

    56789 / 10 = 5678
    56789 % 10 = 9

    would be helpful.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
     
    Jerry Coffin, Sep 18, 2007
    #1
    1. Advertising

  2. Jerry Coffin

    Guest

    hem anyone can give me an idea on how to saparated digits using
    looping

    example

    please key in any 5 digits number : 56789

    and the ouput is
    5678 9
    5678 9
    567 89
    56 789
    5 6789

    huhu how to saparate those digin huhuhu can help???anyone?

    i prefer code in c..
     
    , Sep 18, 2007
    #2
    1. Advertising

  3. Jerry Coffin

    Guest

    On Sep 18, 9:09 pm, Jerry Coffin <> wrote:
    > In article <>,
    > says...
    >
    > > hem anyone can give me an idea on how to saparated digits using
    > > looping

    >
    > > example

    >
    > > please key in any 5 digits number : 56789

    >
    > > and the ouput is
    > > 5678 9
    > > 5678 9
    > > 567 89
    > > 56 789
    > > 5 6789

    >
    > > huhu how to saparate those digin huhuhu can help???anyone?

    >
    > Perhaps the observation that:
    >
    > 56789 / 10 = 5678
    > 56789 % 10 = 9
    >
    > would be helpful.
    >
    > --
    > Later,
    > Jerry.
    >
    > The universe is a figment of its own imagination.


    huhu thx but can you make it clear..huhu im a beginner
     
    , Sep 18, 2007
    #3
  4. Jerry Coffin wrote:
    > In article <>,
    > says...
    >> hem anyone can give me an idea on how to saparated digits using
    >> looping
    >>
    >> example
    >>
    >> please key in any 5 digits number : 56789
    >>
    >> and the ouput is
    >> 5678 9
    >> 5678 9
    >> 567 89
    >> 56 789
    >> 5 6789
    >>
    >> huhu how to saparate those digin huhuhu can help???anyone?

    >
    > Perhaps the observation that:
    >
    > 56789 / 10 = 5678
    > 56789 % 10 = 9
    >
    > would be helpful.


    Or the fact that whatever you enter could just be a string and
    not a number, which then can be split into two substrings at any
    position "between the chars"...

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Sep 18, 2007
    #4
  5. wrote:
    > hem anyone can give me an idea on how to saparated digits using
    > looping
    >
    > example
    >
    > please key in any 5 digits number : 56789
    >
    > and the ouput is
    > 5678 9
    > 5678 9
    > 567 89
    > 56 789
    > 5 6789
    >
    > huhu how to saparate those digin huhuhu can help???anyone?


    Treat the number as text and insert spaces at appropriate places.

    > i prefer code in c..


    Then ask in compl.lang.c and not in a C++ group.

    --
    Erik Wikström
     
    =?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=, Sep 18, 2007
    #5
  6. Jerry Coffin

    Guest

    On Sep 18, 9:31 pm, Erik Wikström <> wrote:
    > wrote:
    > > hem anyone can give me an idea on how to saparated digits using
    > > looping

    >
    > > example

    >
    > > please key in any 5 digits number : 56789

    >
    > > and the ouput is
    > > 5678 9
    > > 5678 9
    > > 567 89
    > > 56 789
    > > 5 6789

    >
    > > huhu how to saparate those digin huhuhu can help???anyone?

    >
    > Treat the number as text and insert spaces at appropriate places.
    >
    > > i prefer code in c..

    >
    > Then ask in compl.lang.c and not in a C++ group.
    >
    > --
    > Erik Wikström- Hide quoted text -
    >
    > - Show quoted text -


    can u check this out..what wrong with these code huhuhu.....

    #include <stdio.h>

    int main(void)
    {
    float num;
    int i, j, x ;

    printf("please key in any 5 digit number:");
    scanf("%f",&num);




    for ( i=0 ; 5>i ; ++i){

    for(j=0 ; i>j ; ++j){
    printf(" ") ;
    }

    for( x = j+1 ; 5 >= x ; ++x){

    printf("%.0f", num);
    }
    putchar('\n');
    }

    return 0;
    }

    what ur comment about this code??is thit mean im almost got the
    answer??
     
    , Sep 18, 2007
    #6
  7. On 2007-09-18 17:01, wrote:
    > On Sep 18, 9:31 pm, Erik Wikström <> wrote:
    >> wrote:
    >> > hem anyone can give me an idea on how to saparated digits using
    >> > looping

    >>
    >> > example

    >>
    >> > please key in any 5 digits number : 56789

    >>
    >> > and the ouput is
    >> > 5678 9
    >> > 5678 9
    >> > 567 89
    >> > 56 789
    >> > 5 6789

    >>
    >> > huhu how to saparate those digin huhuhu can help???anyone?

    >>
    >> Treat the number as text and insert spaces at appropriate places.
    >>
    >> > i prefer code in c..

    >>
    >> Then ask in compl.lang.c and not in a C++ group.
    >>
    >> --
    >> Erik Wikström- Hide quoted text -
    >>
    >> - Show quoted text -

    >
    > can u check this out..what wrong with these code huhuhu.....


    Let us see what is wrong...

    > #include <stdio.h>


    You really should use <iostream> to perform IO operations.

    > int main(void)


    int main()

    > {
    > float num;


    Using a float to store an integer, while not exactly wrong I would not
    recommend it.

    > int i, j, x ;


    Declare the variables int he innermost scope possible.

    > printf("please key in any 5 digit number:");


    std::cout << "Please enter any 5 digits: ";

    > scanf("%f",&num);


    std::cin >> num;

    > for ( i=0 ; 5>i ; ++i){


    for (int i = 0; i < 5; ++i)

    >
    > for(j=0 ; i>j ; ++j){
    > printf(" ") ;
    > }
    >
    > for( x = j+1 ; 5 >= x ; ++x){
    >
    > printf("%.0f", num);
    > }
    > putchar('\n');
    > }
    >
    > return 0;
    > }
    >
    > what ur comment about this code??is thit mean im almost got the
    > answer??


    Did you try running it before posting?

    And once again, if you want to program in C, feel free to do so. But
    then do not come and ask questions in here, where we discuss C++.
    Whatever solution you come up with in C will most probably not be a good
    solution in C++.

    --
    Erik Wikström
     
    =?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=, Sep 18, 2007
    #7
  8. Jerry Coffin

    LR Guest

    wrote:
    > On Sep 18, 9:31 pm, Erik Wikström <> wrote:
    >> wrote:
    >>> hem anyone can give me an idea on how to saparated digits using
    >>> looping
    >>> example
    >>> please key in any 5 digits number : 56789
    >>> and the ouput is


    I'm going to guess that ints on your system can store any 5 digit
    number. Otherwise you might have to use a string to store the digits.
    I suggest that you not use float for this particular assignment.

    [snip]
    Ok, in another thread somewhere you posted that the actual output is,

    and the ouput is
    5678 9
    567 89
    56 789
    5 6789

    I'm going to assume that's correct because it makes more sense.

    Write down a table of what you need.

    You're going to go thru the loop 4 times.
    You'll need some number of spaces before your number.
    You'll need some number of digits.
    You'll need some number of spaces. I'm less sure about this, so I'll
    let you figure that out.
    More digits.

    Make a table like so:
    main spaces before leading spaces trailing
    index number digits digits
    0 0 4 ? 1
    1 2 3 ? 2
    2 4 2 ? 3
    3 6 1 ? 4

    Now think about the relationships between those numbers, for example,
    starting with a number in main index, what will yield the number in the
    same row in the column spaces before number?

    Elsewhere you got good advice about how to deal with the numbers in the
    leading and trailing digits columns.

    Don't use scanf, printf, etc. learn about streams. Learn about std::string.



    >>> huhu how to saparate those digin huhuhu can help???anyone?



    >> Treat the number as text and insert spaces at appropriate places.





    >>> i prefer code in c..


    Oh, sorry, I didn't see that before I responded. I agree with the advice
    given below.


    >> Then ask in compl.lang.c and not in a C++ group.


    In particular the other problem you were asking about that seemed to be
    part of calculating the cost of a meal, will get very different advice
    from c and c++ programmers. So asking here may be less than useful for
    you if you want to program in c.

    OTOH, you may want to ask both c and c++ programmers and decide for
    yourself which answers are more pleasing to you.


    > what ur comment about this code??


    Needs to be better formatted.

    > is thit mean im almost got the
    > answer??


    I don't know. I'm afraid that you'll have to look at the output and
    decide that for yourself.

    LR
     
    LR, Sep 18, 2007
    #8
  9. Jerry Coffin

    Guest

    On Sep 18, 9:16 pm, "Victor Bazarov" <> wrote:
    > Jerry Coffin wrote:
    > > In article <>,
    > > says...
    > >> hem anyone can give me an idea on how to saparated digits using
    > >> looping

    >
    > >> example

    >
    > >> please key in any 5 digits number : 56789

    >
    > >> and the ouput is
    > >> 5678 9
    > >> 5678 9
    > >> 567 89
    > >> 56 789
    > >> 5 6789

    >
    > >> huhu how to saparate those digin huhuhu can help???anyone?

    >
    > > Perhaps the observation that:

    >
    > > 56789 / 10 = 5678
    > > 56789 % 10 = 9

    >
    > > would be helpful.

    >
    > Or the fact that whatever you enter could just be a string and
    > not a number, which then can be split into two substrings at any
    > position "between the chars"...
    >
    > V
    > --
    > Please remove capital 'A's when replying by e-mail
    > I do not respond to top-posted replies, please don't ask- Hide quoted text -
    >
    > - Show quoted text -


    i think it not a string take alook at the quest

    Write a program in C that reads any five digit number and displays the
    number in two parts diagonally as shown in the user interface screen
    as shown below

    Please key in any 5 digit number : 56789

    5678 9
    567 89
    56 789
    5 6789


    The number displayed is separated into two parts beginning with the
    rightmost unit digit.The process continues untill leftmost digit is
    reached
     
    , Sep 18, 2007
    #9
  10. Jerry Coffin

    Guest

    On Sep 19, 12:04 am, LR <> wrote:
    > wrote:
    > > On Sep 18, 9:31 pm, Erik Wikström <> wrote:
    > >> wrote:
    > >>> hem anyone can give me an idea on how to saparated digits using
    > >>> looping
    > >>> example
    > >>> please key in any 5 digits number : 56789
    > >>> and the ouput is

    >
    > I'm going to guess that ints on your system can store any 5 digit
    > number. Otherwise you might have to use a string to store the digits.
    > I suggest that you not use float for this particular assignment.
    >
    > [snip]
    > Ok, in another thread somewhere you posted that the actual output is,
    >
    > and the ouput is
    > 5678 9
    > 567 89
    > 56 789
    > 5 6789
    >
    > I'm going to assume that's correct because it makes more sense.
    >
    > Write down a table of what you need.
    >
    > You're going to go thru the loop 4 times.
    > You'll need some number of spaces before your number.
    > You'll need some number of digits.
    > You'll need some number of spaces. I'm less sure about this, so I'll
    > let you figure that out.
    > More digits.
    >
    > Make a table like so:
    > main spaces before leading spaces trailing
    > index number digits digits
    > 0 0 4 ? 1
    > 1 2 3 ? 2
    > 2 4 2 ? 3
    > 3 6 1 ? 4
    >
    > Now think about the relationships between those numbers, for example,
    > starting with a number in main index, what will yield the number in the
    > same row in the column spaces before number?
    >
    > Elsewhere you got good advice about how to deal with the numbers in the
    > leading and trailing digits columns.
    >
    > Don't use scanf, printf, etc. learn about streams. Learn about std::string.
    >
    > >>> huhu how to saparate those digin huhuhu can help???anyone?
    > >> Treat the number as text and insert spaces at appropriate places.
    > >>> i prefer code in c..

    >
    > Oh, sorry, I didn't see that before I responded. I agree with the advice
    > given below.
    >
    > >> Then ask in compl.lang.c and not in a C++ group.

    >
    > In particular the other problem you were asking about that seemed to be
    > part of calculating the cost of a meal, will get very different advice
    > from c and c++ programmers. So asking here may be less than useful for
    > you if you want to program in c.
    >
    > OTOH, you may want to ask both c and c++ programmers and decide for
    > yourself which answers are more pleasing to you.
    >
    > > what ur comment about this code??

    >
    > Needs to be better formatted.
    >
    > > is thit mean im almost got the

    >
    > > answer??

    >
    > I don't know. I'm afraid that you'll have to look at the output and
    > decide that for yourself.
    >
    > LR


    thx these will be helpfull
     
    , Sep 18, 2007
    #10
  11. Jerry Coffin

    red floyd Guest

    wrote:
    \
    >
    > i think it not a string take alook at the quest
    >
    > Write a program in C that reads any five digit number and displays the
    > number in two parts diagonally as shown in the user interface screen
    > as shown below
    >
    > Please key in any 5 digit number : 56789
    >
    > 5678 9
    > 567 89
    > 56 789
    > 5 6789
    >
    >
    > The number displayed is separated into two parts beginning with the
    > rightmost unit digit.The process continues untill leftmost digit is
    > reached
    >


    You can find an answer at
    http://www.parashift.com/c -faq-lite/how-to-post.html#faq-5.2

    In other words, DO YOUR OWN HOMEWORK.
     
    red floyd, Sep 18, 2007
    #11
  12. Jerry Coffin

    osmium Guest

    <> wrote:

    > i think it not a string take alook at the quest


    *You* take a look at the answers. Jerry Coffin gave the answer your
    instructor probably wants. The time stamps I see show that the answer was
    posted within one minute of the question.

    You must expect wild digressions on a newsgroup such as this, some purposely
    intended to mislead you. It is up to you to separate the wheat from the
    chaff.
     
    osmium, Sep 19, 2007
    #12
    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. senthil
    Replies:
    0
    Views:
    627
    senthil
    Nov 21, 2003
  2. senthil

    ifft coding in vhdl give idea

    senthil, Dec 9, 2003, in forum: VHDL
    Replies:
    1
    Views:
    1,848
  3. davidw
    Replies:
    0
    Views:
    518
    davidw
    Feb 8, 2006
  4. grocery_stocker
    Replies:
    10
    Views:
    640
    Keith Thompson
    May 25, 2005
  5. zidong
    Replies:
    4
    Views:
    635
    backhus
    Oct 8, 2010
Loading...

Share This Page