Pyramid of Asterisks
https://www.programiz.com/c-programming/examples/pyramid-pattern
#include <stdio.h>
int main() {
int i, space, rows, k = 0;
printf("Enter the number of rows: ");
scanf("%d", &rows);
for (i = 1; i <= rows; ++i, k = 0) {
for (space = 1; space <= rows - i; ++space) {
printf(" ");
}
while (k != 2 * i - 1) {
printf("* ");
++k;
}
printf("\n");
}
return 0;
}
Output
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
/* Simple if statement */
https://c.happycodings.com/code-snippets/basic-simple-of-the-if-statement.html
#include <stdio.h>
void main()
{
int number = 0;
printf("\nEnter an integer between 1 and 10: ");
scanf("%d",&number);
if (number > 8)
printf("You entered %d which is greater than 8\n", number);
if (number < 4)
printf("You entered %d which is less than 4\n", number);
}
Output
Enter an integer between 1 and 10: 2
You entered 2 which is less than 4