Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  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 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," 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

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions