I am trying to design the Denmark flag in C through PPM but I can't seem to get my function to work as well as I want to find a more efficient way to loop all the places together, instead of doing all if/else if statements.
for(i=0; i < height; i++){
for(x=0; x < width; x++){
if(x <= width *.3 && i <= height * .3)
{
printf("%i", Pixel(255,51,51));
}
else if(x<= width * .1 && i <= height *.1)
{
printf("%i",Pixel(0,0,0));
}
else if(x <= width * .405 && i <= height *.3)
{
printf("%i", Pixel(255,51,51));
}
else if(x <= width * .4 && i <= height)
{
printf("%i", Pixel(0,0,0));
}
else
{
printf("%i", Pixel(255,51,51));
}
}
}
This is my body, which I have no idea how to loop together instead of creating mass amounts of if/else statements which half the time probably wont work....
void Pixel(int red, int green, int blue){
printf("%i %i %i", red, green, blue);
}
Also for some reason my function will compile... Can anyone help me with this issue as well?