while4.cpp


// while4.cpp
// prints numbers raised to fourth power
#include <iostream>
#include <iomanip>               //for setw to set the width of the output
using namespace std;

int main()
{
	int pow=1;                    //power initially 1
	int numb=1;                   //numb goes from 1 to ???

	while( pow<10000 )            //loop while power <= 4 digits
	{
		cout << setw(2) << numb;         //display number
		cout << setw(5) << pow << endl;  //display fourth power
		++numb;                          //get ready for next power
		pow = numb*numb*numb*numb;       //calculate fourth power
	}
	cout << endl;
	return 0;
}


Results

C:\classes\ece538\work>while4
 1    1
 2   16
 3   81
 4  256
 5  625
 6 1296
 7 2401
 8 4096
 9 6561


Maintained by John Loomis, updated Mon Jan 01 12:33:44 2007