Cycles

Run Settings
LanguageC++
Language Version
Run Command
#include "pch.h" #include <iostream> using namespace std; int main() { cout << "Cycles\n"; // Цикл с предусловием /* while (условие окончания цикла) { // тело цикла } */ int i = 0; while (i < 10) { cout << i++ << endl; } cout << endl; // Цикл с постусловием /* do { // тело цикла } while (условие окончания цикла); */ i = 100; do { cout << i++ << endl; } while (i < 10); int temperature; do { cout << endl << "Input the temerature of your body"; cin >> temperature; // } while (temperature > 42 || temperature < 34); // или так } while (!(temperature <= 42 && temperature >= 34));// или так cout << temperature; // Переход по метке cout << "Using GOTO"; label1: cout << endl << "Input the temerature of your body"; cin >> temperature; if (temperature > 42 || temperature < 34) goto label1; // Цикл с заданным числом итераций int k; for (k = 0; k < 10; k++) { cout << k << endl; } cout << k << endl; double z; // z = 5*x + 1 / y, x = -5 .. +5, step 0.1, y = 0 .. 20, step 0.5 for (double x = -5; x <= 5; x+=0.1 /* x = x + 0.1;*/) { for (double y = 0; y <= 20; y+=0.5) { if (0 != y) { z = 5 * x - 1 / y; cout << endl << x << "\t" << y << "\t" << z; } else //cout << endl<< "No solution at y = 0"; continue; // переход к следующей итерации цикла //break; // прерываем выполнение цикла } if (x == 0) continue; } // сравнение вещественных чисел double a = 2.0, b = 2.0; if (abs(a-b) < 1E-14) // (a == b) cout << endl << "=============="; }
Editor Settings
Theme
Key bindings
Full width
Lines