C++ help

Discussion in 'Programming General' started by The Riddler_, May 24, 2012.

C++ help
  1. Unread #1 - May 24, 2012 at 6:11 PM
  2. The Riddler_
    Joined:
    Nov 28, 2008
    Posts:
    2,779
    Referrals:
    3
    Sythe Gold:
    0

    The Riddler_ Grand Master
    Banned

    C++ help

    Hey, i'm using the Dev C++ compiler, and typically when I compile my code it runs movely, no erros, but when I run the programs, some of them don't do anything after the "cout's". I'll run the program, it prompts me the cout that I have, but it does nothing after that.

    Here's the code.

    Code:
    #include <iostream.h>
    #include <math.h>
    #include <stdlib.h>
    
    int main()
    {
    	double h;
    	double t = 0.0;
    	double v = 0.0;
    	double s = 0.0;
    	cout << "Whats is the height of the object?" << endl;
    	cin >> h;
    	cout << h;
    	while(h > 0);
    	{
    		t++;
    		h--;
    		v = t * 32.0;
    		s = t * t * 16.0;
    		cout << "The volocity is " << v << ", The height of the object is " << h << 
    		", and " << t << "seconds have gone by";
    	}
    }
    
    Just a simple program.

    Thanks.
     
  3. Unread #2 - May 28, 2012 at 11:39 PM
  4. ilovegold69
    Joined:
    Aug 28, 2011
    Posts:
    1,195
    Referrals:
    0
    Sythe Gold:
    77
    Doge I'm LAAAAAAAME

    ilovegold69 Guru

    C++ help

    you're missing an endl; after your cout statement

    Code:
    cout << "The volocity is " << v << ", The height of the object is " << h << ", and " << t << "seconds have gone by" endl;
     
  5. Unread #3 - May 29, 2012 at 6:18 PM
  6. T7 Press 7T
    Joined:
    Jun 14, 2007
    Posts:
    384
    Referrals:
    0
    Sythe Gold:
    0

    T7 Press 7T Forum Addict

    C++ help

    Could be because you forgot:
    Code:
    using namespace std;
    After your header files.
     
< how do windows applications work? | Best "language" for Mac coding? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site