fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int rows = 4, cols = 3;
  5. int i, j;
  6.  
  7. // Width of each cell
  8. int cellWidth = 10;
  9.  
  10. // Print top border
  11. for (i = 0; i < cols; i++) {
  12. printf("+");
  13. for (j = 0; j < cellWidth; j++) printf("-");
  14. }
  15. printf("+\n");
  16.  
  17. // Print rows
  18. for (i = 0; i < rows; i++) {
  19. // Print cell content row
  20. for (j = 0; j < cols; j++) {
  21. printf("|%-*s", cellWidth, ""); // Empty cell
  22. }
  23. printf("|\n");
  24.  
  25. // Print border after each row
  26. for (j = 0; j < cols; j++) {
  27. printf("+");
  28. for (int k = 0; k < cellWidth; k++) printf("-");
  29. }
  30. printf("+\n");
  31. }
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
+----------+----------+----------+
|          |          |          |
+----------+----------+----------+
|          |          |          |
+----------+----------+----------+
|          |          |          |
+----------+----------+----------+
|          |          |          |
+----------+----------+----------+