Табулирование функции y=x^2 на интервале [-6, 6] с шагом 1:
1.
#include
using namespace std;
int main() {
for (int x=-6; x<=6; x++)<br> cout << "x = " << x << " y = " << x*x << "\n";<br> return 0;
}
2.
#include
using namespace std;
int main() {
int x=-6;
while (x<=6) {<br> cout << "x = " << x << " y = " << x*x << "\n";<br> x += 1;
}
return 0;
}
3.
#include
using namespace std;
int main() {
int x=-6;
do {
cout << "x = " << x << " y = " << x*x << "\n";<br> x += 1;
}
while (x<=6);<br>return 0;
}
Результат:
x = -6 y = 36
x = -5 y = 25
x = -4 y = 16
...
x = 5 y = 25
x = 6 y = 36