Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void) {
- int height;
- printf("Please enter the height of the first half of the diamond:\n");
- scanf("%d", &height);
- if (height < 1) {
- printf("Invalid user input. Minimum size of the diamond is one.\n");
- return 0;
- }
- for (int y = 0; y <= height * 2; y++) {
- for (int x = 0; x <= height * 2; x++) {
- if (x + y == height || x - y == height ||
- y - x == height || x + y == 3 * height)
- printf("*");
- else
- printf(" ");
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement