Thread: Need some help..

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    19

    Need some help..

    Enter N: 4

    2 = 2
    2 + 4 = 6
    2 + 4 + 6 = 12
    2 + 4 + 6 + 8 = 20

    that is the out put .. if i enter the number 5 is taht mean everything oging to change?


    well here is what i did .. some of it ..

    int main()
    {

    int n;

    cout<<"ENTER N:";
    cin>>n ;

    cout<<"\t" << n/2<<"="<<"\t"<<n/2<<"\t";


    cout<<endl;


    When you enter 4 it will cout 2 = 2

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    I don't quite see what you're doing. Yes your program will have to change for 5 because 5 / 2 = 2.5 . This is a floating point number and cannot be represented using an integer accurately. Change your data types to floats and try it out.

  3. #3
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    5/2 =2.5
    2.5=2.5

    what do you mean will it change when the input is 5? why don't you try it?
    plus it should be obvious that n/2=n/2, it's mathmatical law.
    PHP and XML
    Let's talk about SAX

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    19
    Ok so your guys know waht i'm doing. I just want to make sure i'm on the right track..

    thx for reply..




    ya i change the int to float so now when i enter 5 it will cout 2.5 = 2.5

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    19
    #include <iostream.h>
    #include <stdlib.h>

    int main()
    {

    float n;


    cout<<"ENTER N:";
    cin>>n ;

    cout<<"\t" <<n/2<<"="<<"\t"<<n/2<<"\t";

    cout<<"\t"<<n/2<<"+"<<n<<"="<<n+n/2;

    cout<<"\t"<<n/2<<"+"<<n<<"+"<<n+n/2<<"="<<n+n+n;

    cout<<"\t"<<n/2<<"+"<<n<<"+"<<n+n/2<<"+"<<n+n<<"="<<n+n+n+n+n;



    cout<<endl;


    system("PAUSE");
    return 0;
    }




    2 = 2 2 + 4 = 6 2 + 4 +6=12 2+4+6+8=20


    how can u make it

    2 = 2
    2+4=6
    2+4+6=12
    2+4+6+12=20
    Last edited by Aznmask; 12-03-2002 at 06:28 PM.

  6. #6
    Registered User
    Join Date
    Nov 2002
    Posts
    19

    Problem again

    Enter n: 4


    6 * 7 = 42
    66 * 67 = 4422
    666*667= 444222
    6666*6667= 44442222


    i wonder if i enter 5? or 6 what will happen..anyone got instruction to do it?

  7. #7
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    I don't understand what you are trying to do. Make line breaks??
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    19
    Ya.. i want to break it into line

  9. #9
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Code:
    std::cout << "asdf" << std::endl << "hello"; //maybe the *best* method, not sure
    or 
    std::cout << "asdf" << "\n" << "hello"; //not a good method at all
    or 
    std::cout << "asdf\nhello"; //my preferred method, it's easiest
    output:
    Code:
    asdf
    hello
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  10. #10
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    first of all, don't post a new thread on the same program

    second of all, why don't you PUT IN 5 AND SEE FOR YOURSELF.

    THIRD,
    we have no freakin clue what's going to happen cause all we see is output, do you even know what you're doing? Read the rules man, I know of 2 that you're violating.
    PHP and XML
    Let's talk about SAX

  11. #11
    Registered User
    Join Date
    Nov 2002
    Posts
    19
    o ya i forgot about the \n command..

  12. #12
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>first of all, don't post a new thread on the same program
    Merged by me.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  13. #13
    Registered User
    Join Date
    Nov 2002
    Posts
    19
    Originally posted by Waldo2k2
    first of all, don't post a new thread on the same program

    second of all, why don't you PUT IN 5 AND SEE FOR YOURSELF.

    THIRD,
    we have no freakin clue what's going to happen cause all we see is output, do you even know what you're doing? Read the rules man, I know of 2 that you're violating.

    first i didnt post a new thread on a SAME program

    second i did put 5 it goes by 2.5 = 2.5 czu i change the int to float.

    third "READ what wrote"

  14. #14
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    >>first i didnt post a new thread on a SAME program

    yes you did, the mods combined em just recently (my post was pushed out of order but still)
    all that was different was you multiplying or something, same basic program, don't nitpick.

    second, here's your exact post that got moved to this thread
    Enter n: 4


    6 * 7 = 42
    66 * 67 = 4422
    666*667= 444222
    6666*6667= 44442222


    i wonder if i enter 5? or 6 what will happen..anyone got instruction to do it?
    what is that??
    no code, no nothing, i was reading what was written, that's all there was.

    third
    >>i wonder if i enter 5? or 6 what will happen..anyone got instruction to do it?
    learn how to ask a question, what DO you want to know?
    PHP and XML
    Let's talk about SAX

  15. #15
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Perhaps we should just all ignore him? Now he sort of sounds like one of those spammers who are just out to ........ people off...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed