Demo: Play Computer With Nested Loops

Play computer step by step by clicking on the step button. Each time you click you get to see the next step and its effect on the variables and the screen. Scroll up to see both the program, the variables and screen.

  1. #include<stdio.h>
  2. int main() {
  3. int bNum;
  4. printf("Please enter the number of b's: ");
  5. scanf("%d", &bNum);
  6. while (bNum>=1)
  7. {
  8. printf("a");
  9. int i=0;
  10. while (i<bNum)
  11. {
  12. printf("b");
  13. i++;
  14. }
  15. bNum--;
  16. }
  17. }