In: Computer Science
I'm having trouble trying to create the italian, polish, and netherlands flag in C
Here's my code so far:
#include<stdio.h>
int main(){
int country_choice;
fprintf(stderr, "Enter the country_code of the chosen flag.(1 for Poland, 2 for Netherlands, 3 for Italy)");
fscanf(stdin, "%d", &country_choice);
switch (country_choice) {
case 1:
printf("Poland Flag\n");
printf("%c%c%c", 255,255,255);
printf("%c%c%c", 220,20,60);
break;
case 2:
printf("Italian Flag\n");
printf("%c%c%c", 0,146,70);
printf("%c%c%c", 225,255,255);
printf("%c%c%c", 206,43,55);
break;
case 3:
printf("Netherlands Flag\n");
printf("%c%c%c", 174,28,40);
printf("%c%c%c", 225,255,255);
printf("%c%c%c", 33,70,139);
break;
default:
printf("Wrong Option");
break;
}
return(0);
}
#include<stdio.h>
int main(){
int country_choice,height,width,i; //declaring width and height of the flag
fprintf(stderr, "Enter the country_code of the chosen flag.(1 for Poland, 2 for Netherlands, 3 for Italy)");
fscanf(stdin, "%d", &country_choice);
fprintf(stderr, "Enter the width of the flag");
fscanf(stdin, "%d", &width);
height= (width*2)/3;
switch (country_choice) {
case 1:
for (i = 0; i < height; i++) {
for (i = 0; i < width / 3; i++)
printf("%c%c%c", 225,255,255);
for (i = 0; i < width / 3; i++)
printf("%c%c%c", 220,20,60);
}
break;
case 2:
printf("Italian Flag\n");
for (i = 0; i < height; i++) {
for (i = 0; i < width / 3; i++)
printf("%c%c%c", 0,146,70);
for (i = 0; i < width / 3; i++)
printf("%c%c%c", 225,255,255);
for (i = 0; i < width / 3; i++)
printf("%c%c%c", 206,43,55);
}
break;
case 3:
printf("Netherlands Flag\n");
for (i = 0; i < height; i++) {
for (i = 0; i < width / 3; i++)
printf("%c%c%c", 174,28,40);
for (i = 0; i < width / 3; i++)
printf("%c%c%c", 225,255,255);
for (i = 0; i < width / 3; i++)
printf("%c%c%c", 33,70,139);
}
break;
default:
printf("Wrong Option");
break;
}
return(0);
}