tubeshowcase●1,194,391 videos♡ My collection 0
← Learn to Code

Learn to Code11:27

While loops in C are easy! ♾️

Bro Code ↗

From the creator

#coding #programming #cprogramming // while loop = Continue some code WHILE the condition remains true // Condition must be true for us to enter while loop // ---------- EXAMPLE 2 ---------- char name[50] = ""; printf("Enter your name: "); fgets(name, sizeof(name), stdin); name[strlen(name) - 1] = '\0'; while (strlen(name) == 0) { printf("Name cannot be empty! Please enter your name: "); fgets(name, sizeof(name), stdin); name[strlen(name) - 1] = '\0'; } printf("Hello %s!", name); // ---------- EXAMPLE 3 ---------- bool isRunning = true; char response = '\0'; while(isRunning){ printf("You are playing a game\n"); printf("Would you like to continue? (Y = yes, N = no): "); scanf(" %c", &response); // remove \n from input buffer if(response != 'Y' && response != 'y'){ isRunning = false; } } printf("You exit the game"); return 0;

Published 2025-03-19 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code