Program failure

This is a discussion on Program failure within the C++ Programming forums, part of the General Programming Boards category; I have tried to make a program but it fails when compiled and run. Could someone check it out and ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    16

    Program failure

    I have tried to make a program but it fails when compiled and run. Could someone check it out and tell me what's wrong.

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
      int thisisanumber;
    
      cin>> thisisanumber;
      cin.ingnore();
      if ( thisisanumber > 5 ) {
     cout<<"hi"; 
    } 
      
     
      
    
      cin.get();
      return 0;
    }
    My intention is to enter any number which is over 5 so i get the message hi..
    Last edited by cnoob; 01-14-2005 at 11:40 AM.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,205
    Code:
      if ( thisisanumber <5 ) {
     cout<<"hi"; 
    }
    Also your brackets doesnt add up.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    16
    Doesn't ring a bell.

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    1,205
    you last '{' shouldnt be there.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    16
    K, but i get also an error with int main().

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    ...and the error is...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #7
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    I don't see any errors (except spelling). I get a warning when I compile, which is resolved by putting a return 0; at the end of your code.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    16
    /Documents and Settings/John Doe/Desktop/Uusi kansio2/old.cpp C:\Documents and Settings\John Doe\Desktop\Uusi kansio2\C In function `int main()':

  9. #9
    Registered User
    Join Date
    Jan 2005
    Posts
    16
    10 C:\Documents and Settings\John DOe\Desktop\Uusi kansio2\old.cpp ` ingnore' undeclared (first use this function)

  10. #10
    Registered User
    Join Date
    Aug 2003
    Posts
    1,205
    and the part after that line??

  11. #11
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,805
    You spelled ignore wrong.
    It's:
    Code:
    cin.ignore();
    Not:
    Code:
    cin.ingnore();
    Woop?

  12. #12
    Registered User
    Join Date
    Jan 2005
    Posts
    16
    Oops, lol.

  13. #13
    Registered User
    Join Date
    Jan 2005
    Posts
    16
    Hurray lol it works. Thanks all

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  2. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21