write a program to print hut using Cout computer science
Answers
Answer:
#include<stdio.h>
int main() {
int i, j, space, rows = 8, star = 0;
/* Printing upper triangle */
for (i = 0; i < rows; i++) {
if (i < 5) {
/* Printing upper triangle */
for (space = 1; space < 5 - i; space++) {
printf(" ");
}
/* Printing stars */
while (star != (2 * i + 1)) {
printf("*");
star++;;
}
star = 0;
/* move to next row */
printf("\n");
} else {
/* Printing bottom walls of huts */
for (j = 0; j < 9; j++) {
if ((int) (j / 3) == 1)
printf(" ");
else
printf("*");
}
printf("\n");
}
}
return 0;
}
Question:
write a program to print hut using Cout computer science
Answer:
Program to print Hut Star pattern
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:Input: N = 5
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:Input: N = 5Output:
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:Input: N = 5Output: *
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:Input: N = 5Output: * * * *
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:Input: N = 5Output: * * * * * * * * *
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:Input: N = 5Output: * * * * * * * * * * * * * * * *
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:Input: N = 5Output: * * * * * * * * * * * * * * * * * * * * * * * * *
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:Input: N = 5Output: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:Input: N = 5Output: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:Input: N = 5Output: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Program to print Hut Star patternGiven a number N such that N >= 5. The task is to print a Hut Star Pattern with (N + 3) rows as shown in the below examples.Examples:Input: N = 5Output: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Input: N =7
Approach: The upper N rows od the pattern will be a triangle and the last 3 rows will contain two space-separated rectangles as shown in the above examples.
Hope it helps uh mate