This code makes an ASCII representation of a Sierpinski triangle of order 4, and I have no idea how the last printf works. If anyone can explain it to me, I would be very grateful.
#include <stdio.h>
#define SIZE (1 << 4)
int main()
{
int x, y, i;
for (y = SIZE - 1; y >= 0; y--, putchar('\n')) {
for (i = 0; i < y; i++) putchar(' ');
for (x = 0; x + y < SIZE; x++)
printf((x & y) ? " " : "* ");
}
return 0;
}
&operator does? Do you know the? :conditional operator? Break it down into pieces and it should become clear.(x & y)evaluates to true, it prints a " ", otherwise a "* ".