I need to produce the flags of Poland, Netherlands and Italy using these steps in C programming: Use fprintf(stderr, ...) to prompt the user for input. Use an if-else or switch statement based on the country_code and put the code to create the flags within each part of the if-else or switch, whichever you have chosen. Use nested for loops to iterate through the image, and generate an image of the correct size as determined by the user’s input to width. Determine what row and column the program is currently iterating through, and write the correct color based on where on the flag that is. Here is the code I have so far: #include #include void make_pixel(int r, int g, int b); void make_ppm_header(int width, int height); void make_ppm_image(int country_code, int width); int main(){ //declaring variables int country_code; int width; int height; int i; //j, k, t; //asking for user input fprintf(stderr, "What country's flag do you want to create? "); fscanf(stdin,"%d",&country_code); fprintf(stderr,"What width (in pixels) do you want it to be? "); fscanf(stdin, "%d", &width); fprintf(stderr,"\nMaking country %d's flag with %d pixels...\n", country_code, width); i = 0; //Poland flag if((country_code == 1)){ void make_ppm_image(int country_code, int width); fprintf(stdout, "P6\n%d 400 255\n", width); for(i=0; i<400*400; i++){ printf("%c%c%c",255,255,255); printf("%c%c%c",255, 0, 0); } } fprintf(stderr, "Done!\n\n"); return(0); } //Netherlands flag if((country_code == 2)){ void make_ppm_image(int country_code, int width); } //Italy flag
I need to produce the flags of Poland, Netherlands and Italy using these steps in C
-
Use fprintf(stderr, ...) to prompt the user for input.
-
Use an if-else or switch statement based on the country_code and put the code to create the
flags within each part of the if-else or switch, whichever you have chosen.
-
Use nested for loops to iterate through the image, and generate an image of the correct size as
determined by the user’s input to width.
-
Determine what row and column the program is currently iterating through, and write the correct color
based on where on the flag that is.
Here is the code I have so far:
#include<stdio.h>
#include<stdlib.h>
void make_pixel(int r, int g, int b);
void make_ppm_header(int width, int height);
void make_ppm_image(int country_code, int width);
int main(){
//declaring variables
int country_code;
int width;
int height;
int i; //j, k, t;
//asking for user input
fprintf(stderr, "What country's flag do you want to create? ");
fscanf(stdin,"%d",&country_code);
fprintf(stderr,"What width (in pixels) do you want it to be? ");
fscanf(stdin, "%d", &width);
fprintf(stderr,"\nMaking country %d's flag with %d pixels...\n", country_code, width);
i = 0;
//Poland flag
if((country_code == 1)){
void make_ppm_image(int country_code, int width);
fprintf(stdout, "P6\n%d 400 255\n", width);
for(i=0; i<400*400; i++){
printf("%c%c%c",255,255,255);
printf("%c%c%c",255, 0, 0);
}
}
fprintf(stderr, "Done!\n\n");
return(0);
}
//Netherlands flag
if((country_code == 2)){
void make_ppm_image(int country_code, int width);
}
//Italy flag
Trending now
This is a popular solution!
Step by step
Solved in 2 steps