Help with changing a program

Hello, i would like to change this program that someone on this forum helped me make, the program works fine, but i dont know how to make it only show the 4th root of even numbers from 2-20

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int numb; 
for(numb=0; numb<=30; numb++) 
{
if(numb%2!=0){
cout << setw(4) << numb; 
int cube = numb*numb*numb; 
cout << setw(6) << cube << endl;
}//end if 
}
system("PAUSE");
return 0;
}
closed account (o3hC5Di1)
Hi there,

Some hints:

- "of numbers 2-20" - you will have to change your for-loop on line 7.
- you will need to introduce a way that calculates the fourth power of a number so you can check it against "the even number between 2 and 20".

Please have a go at modifying the code and come back to us with any specific issues you encounter.

All the best,
NwN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
	int numb; 
	for(numb=0; numb<=30; numb++) {
		if(numb%2==0) { //here
			cout << setw(4) << numb; 
			int quad = numb*numb*numb*numb; //and here
			cout << setw(8) << quad << endl;
		} 
	}
	system("PAUSE");
	return 0;
}
Last edited on
i changed it to theis

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int numb; 
for(numb=2; numb<=20; numb++) 
{
if(numb%2!=0){
cout << setw(4) << numb; 
int cube = numb*numb*numb*numb; 
cout << setw(8) << cube << endl;
}//end if 
}
system("PAUSE");
return 0;
}

And I'm assuming i have to change line 9 somehow, but i'm stuck.
Thanks guys. i got it, thanky ou for the help once again, i love this site!!
Topic archived. No new replies allowed.