0

# How do I find the sq of all even numbers between 10 to 30 using while and do while loop?

7 Answers

0

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int a = 1;
while (a < 2) {
for (int a = 10; a < 31; a+=2) {
cout << pow(a,2) << endl;
}
a++;
}
return 0;
}
---------------------
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int a = 10;
do {
cout << pow(a,2) << endl;
a = a + 2;
} while(a < 31);
return 0;
}

0

why did you use
#include <math.h>
??
wht does it mean
jaque!!???

0

math.h allows you to use different mathematical functions, I had to declare (C library) math.h to use pow(base,exp). It's like <stdio.h> with printf. It allows you to use alot more functions like sqrt(data type variable);. Tip: You can also sqrt with pow(base,0.5) make sure you watch data types.

0

so, without this statmnt can we also print something and what's this pow .... its a basic of c++ or high lvl

0

Yes you can print without it it's just optional for doing additional maths. pow is raising a number to a certain power ex. 5^2 is 5 * 5 , 5^3 5*5*5. It's a basic but idk if they cover it in this course. <iostream> is what you'll mainly be using here but there are others like <ctime> , etc you'll see in the course.

0

#include <iostream>
using namespace std;
int main()
{
int a = 10;
do {
cout << a * a << endl;
a = a + 2;
} while(a < 31);
return 0;
}
is it not using math.h or pow

0

thanks so much guys.