DEV Community

Mahamadjon000
Mahamadjon000

Posted on

1

do while

do while - это цикл который выполняет код хотя бы один раз если условие окажется false. Потом он продолжает повторятся пока условие окажется true.

Нужно оброшать внимание на ; после условия - она обязательна!

Пример кода:

#include <iosream>

using namespace std;

int main()
{

int number = 10;

do
{
cout << "Number" << number << endl;

}while(number < 5)

return 0;
}
Enter fullscreen mode Exit fullscreen mode

Обьяснение кода:

Это программа выведет Number 10 один раз несмотря на то что условие number < 5 false.

Top comments (0)

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay