C++: print out 10 lines of 5 $ signs using the nested loop


SUBMITTED BY: Guest

DATE: Oct. 28, 2013, 3:58 p.m.

FORMAT: C++

SIZE: 458 Bytes

HITS: 838

  1. // PURPOSE: To write a program that print out 10 lines of 5 $ signs using the nested loop
  2. #include <stdio.h>
  3. int main()
  4. {
  5. int i; // row number, goes from 1 to 10
  6. int j; // column number, goes from 1 to 5
  7. i = 1;
  8. while (i <= 10)
  9. {
  10. j = 1;
  11. while (j <= 5)
  12. {
  13. printf("$");
  14. j = j + 1;
  15. }
  16. i = i + 1;
  17. printf("\n");
  18. }
  19. getchar();
  20. getchar();
  21. return 0;
  22. }

comments powered by Disqus