Question
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
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 users 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
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," Making country %d's flag with %d pixels... ", country_code, width);
i = 0;
//Poland flag if((country_code == 1)){ void make_ppm_image(int country_code, int width); fprintf(stdout, "P6 %d 400 255 ", 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! "); return(0); } //Netherlands flag if((country_code == 2)){ void make_ppm_image(int country_code, int width); }
//Italy flag
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started