While loop output error.

Hello again, alone I've managed to get my program up and working and directed any little questions to my lecturer. I'm sorry that last time it seemed my statement was ambiguous for anyone that thought I needed code. So here I'll make it quite brief. I simply need to find out why my program is not outputting during this while statement.
I'll only provide the sections of my code needed for the statement.

Header
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
 
#include <iostream>

using namespace std;

#ifndef FUN_H

#define FUN_H


class Fun
{
public:



    Fun(long int number)//Overload Constructor(sets newNumber to Number entered)
    {
        newNumber=number;


    }

long int power(int base, int exponent)
    {
        int count;      //Loop counter.
        int newBase;  //Used so the original base can remain as the figure entered.
        count=1;
        newBase=1;
       while (count <= exponent)

       {

          newBase*=base;

            ++count;



           }

        return newBase;
    }


    /*long int getnewNumber()//Displays the number that was entered (only for assuring the code is working)
    {
        return newNumber;
    }*/

    void leTable()
    {
        int numbero=0;

        while(numbero >=10)

        {
       cout<<power(numbero,1)<<"\t"<<power(numbero,2)<<"\t"power(numbero,3)<<endl;
         
          ++numbero;
                 }

    }

private:
        //Member Variable
                long int newNumber;


                

};

#endif 



.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

#include <iostream>
using namespace std;

#include "fun.h"

int main()
{


   Fun Thisobject;
   
    Thisobject.leTable();
    return 0;

}



If im missing any parenthesis symbols outside of the while loop its simply a copy and paste error. Besides that I'm more worried about why I'm not getting any output unless I declare it outside of the loop.


Last edited on
1
2
3
4
5
6
int numbero=0;

while(numbero >=10) {
       cout<<power(numbero,1)<<"\t"<<power(numbero,2)<<"\t"power(numbero,3)<<endl;
       ++numbero;
}

Zero is assigned to numbero when the member function(method) is called. The while loops condition is only true if numbero is more than or equal to ten, which it is not. There's your problem. To fix it, simply change the while loops condition to while(numero <= 10).
Last edited on
(I want to go hang myself right now) Need to relearn preschool style, sorry I overlooked the whole big fish small fish concept with the angle brackets. Thanks and I'll try to keep my questions as specific as this next time. Again thanks so much.
Topic archived. No new replies allowed.