Adblock breaks this site

What went wrong?

Discussion in 'Programming General' started by booyaboy234, Aug 7, 2008.

  1. booyaboy234

    booyaboy234 Newcomer

    Joined:
    Aug 7, 2008
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0
    What went wrong?

    I'm trying to write a program in dev c++ that squares numbers buit i cant find out what is going wrong when i try to compile it. I was hoping someone here could.
    Code:
    //
     //   program to convert integers to there squares
     //
     #include <cstdio> 
     #include <iostream>
     using namespace std;
     
     int main(int nNumberofArgs, char* pszArgs[])
     {
     //enter numbr to be squared
     int number;
     cout << "enter number to be squared:";
     cin >> number;
     
     // use conversion factor to convert numeral
     // into square
     int integer;
     square = number * number;
     
     // output results (followed by a NewLine)
     cout << "squared value is:";
     cout << square << end];
     
     // wait until user is ready to terminater program
     // to allow user to view results
     system("PAUSE");
     return 0;
    }
     
    
     
  2. Govind

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus
    What went wrong?

    int integer;
    should be int square
     
  3. cp

    cp an cat
    Banned

    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0
    What went wrong?

    Code:
     cout << square << end];
    Shouldn't that be endl?
     
  4. booyaboy234

    booyaboy234 Newcomer

    Joined:
    Aug 7, 2008
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0
    What went wrong?

    I actually didn't need that line at all.
    and thanks alot SMR
     
  5. Swan

    Swan When They Cry...
    Retired Global Moderator

    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner
    What went wrong?

    You do need that line if you intend on displaying the squared number.

    Isn't there an operator for powers anyway? '^' (or is that bitwise XOR?)
     
  6. Govind

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus
    What went wrong?

    C++ doesn't use ^ for exponents. But there's pow() in math.h.
     
  7. booyaboy234

    booyaboy234 Newcomer

    Joined:
    Aug 7, 2008
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0
    What went wrong?

    sorry, i meant the "end]" part
     
  8. Swan

    Swan When They Cry...
    Retired Global Moderator

    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner
    What went wrong?

    What you could actually do is rather than

    Code:
    << endl;
    For newlines, you can use escape characters if you still have an "open string", e.g.

    Code:
     cout << "example string\n"; 
    And so on.

    It would be good if you also checked out the printf and s_printf functions inside stdio (I think that's the header file, but they may be included in Iostream too, not sure).

    SMR:

    Thanks for clearing that up. I've been using C# way too much recently (either that or I'm completely mucked up in the head when it comes to operators, either or)
     
  9. Govind

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus
    What went wrong?

    NP. Also, printf_s*
     
< Help with a private server on silkroad online | Whats the code so that when someone types the info on the visual it sends to u email >


 
 
Adblock breaks this site