While loops in C are easy! ♾️ @BroCodez
While loops in C are easy! ♾️  @BroCodez
Uploaded March 2025 | Updated September 2026, 2 weeks ago
#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;
While loops in C are easy! ♾️Learn Java enhanced switches in 8 minutes! 💡Learn POLYMORPHISM in 6 minutes! 🎭Functions in C are easy! 📞Learn Python VARIABLES in 10 minutes! ❎Lets code a mad libs game with Java! 📖Python PyQt5 IMAGES are easy! 📷Useful NumPy functions you should know! 🎚️Learn Python in 1 hour! 🐍NumPy aggregate functions are easy! 📊Learn Python PyQt5 in 1 hour! 🐍Learn Java arrays in 9 minutes! 🍎
Bro Code |

While loops in C are easy! ♾️

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER