Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program called flags.c that is capable of creating an image of the flags of Poland, Netherland, and Italy. country_code should be 1, 2,

Write a program called flags.c that is capable of creating an image of the flags of Poland, Netherland, and Italy. country_code should be 1, 2, and 3 for Poland, the Netherlands, and Italy, respectively.

You will need to write the code to create the chosen flag. To do this youll need to:

1. Use fprintf(stderr, ...) to prompt the user for input.

2. 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.

3. 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.

4. 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's my code 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(){

int width=0;

int country_code=0;

fprintf(stderr, "Enter the country_code of the chosen flag.(1 for Poland, 2 for Netherlands, 3 for Italy)");

fscanf(stdin, "%d", &country_code);

fprintf(stderr, "What width(in pixels) do you it be?");

fscanf(stdin, "%d", &width);

fprintf(stderr, " Making country %d's flag with width %d pixels... ",country_code,width);

return(0);

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is a government-sponsored enterprise?

Answered: 1 week ago