Question

In: Computer Science

I'm having trouble trying to create the italian, polish, and netherlands flag in C Here's my...

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);

}

Solutions

Expert Solution

#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);

}


Related Solutions

I'm having difficulty trying to make my code work. Create a subclass of Phone called SmartPhone....
I'm having difficulty trying to make my code work. Create a subclass of Phone called SmartPhone. Make this subclass have a no-arg constructor and a constructor that takes a name, email, and phone. Override the toString method to return the required output. Given Files: public class Demo1 { public static void test(Phone p) { System.out.println("Getter test:"); System.out.println(p.getName()); System.out.println(p.getNumber()); } public static void main(String[] args) { Phone test1 = new SmartPhone(); Phone test2 = new SmartPhone("Alice", "8059226966", "[email protected]"); System.out.println(test1); System.out.println(test2); System.out.println(test1);...
I'm having trouble with my ZeroDenominatorException. How do I implement it to where if the denominator...
I'm having trouble with my ZeroDenominatorException. How do I implement it to where if the denominator is 0 it throws the ZeroDenominatorException and the catch catches to guarantee that the denominator is never 0. /** * The main class is the driver for my Rational project. */ public class Main { /** * Main method is the entry point to my code. * @param args The command line arguments. */ public static void main(String[] args) { int numerator, denominator =...
I'm having trouble with validating this html code. Whenever I used my validator, it says I...
I'm having trouble with validating this html code. Whenever I used my validator, it says I have a stray end tag: (tbody) from line 122 to 123. It's the last few lines. Thanks and Ill thumbs up whoever can help solve my problem. Here's my code: <!DOCTYPE html> <html lang="en"> <head> <title>L7 Temperatures Fields</title> <!--    Name:    BlackBoard Username:    Filename: (items left blank for bb reasons    Class Section: (blank)    Purpose: Making a table to demonstrate my...
Hey! I'm having trouble answering this for my assignment. Thank you so much in advance. 1)...
Hey! I'm having trouble answering this for my assignment. Thank you so much in advance. 1) Which type of vessels, arteries or veins, has more muscle fibers? What is the functional significance of this? 2a) In general, we have no conscious control over smooth muscle or cardiac muscle function, whereas we can consciously control to some extent all skeletal muscles. Can you consciously control your breathing? What does this tell you about the muscle type of the diaphragm? 2b) What...
Using dev c++ I'm having trouble with classes. I think the part that I am not...
Using dev c++ I'm having trouble with classes. I think the part that I am not understanding is sending data between files and also using bool data. I've been working on this program for a long time with many errors but now I've thrown in my hat to ask for outside help. Here is the homework that has given me so many issues: The [REDACTED] Phone Store needs a program to compute phone charges for some phones sold in the...
I'm having trouble thinking of a way that I can delete duplicates from a c string...
I'm having trouble thinking of a way that I can delete duplicates from a c string of alphabets. So what I'm supposed to do is I'm supposed to delete the repeated letters in the c string using pointers and also dynamically allocating space. I'm guessing that I will have to dynamically allocate space for an array to put in the letters that only appear once. To do that, can I create 2 pointers in a function and have 1 pointer...
I'm having trouble creating a histogram using openCV (color segmentation)
I'm having trouble creating a histogram using openCV (color segmentation)
I'm having trouble programming connect four board game using linked lists, sets and maps in c++....
I'm having trouble programming connect four board game using linked lists, sets and maps in c++. Can you code connect four game using these concepts.
We are learning about Ramayana in Mythology and I'm having a bit of trouble understanding the...
We are learning about Ramayana in Mythology and I'm having a bit of trouble understanding the story. Why would Rama be set apart as a true hero? The story of Rama and Sita is a favorite story that parents tell their children. What purpose does the Ramayana serve as an instructional story for Indian culture? What effect do the test and temptations have on the heroic character?
I'm having trouble with these few questions out of a long list of journal entries that...
I'm having trouble with these few questions out of a long list of journal entries that I have to record for a project. If you could please state the journal entries for these and why that would be very helpful. Thank you! May 2 – Sold merchandise on credit to Yellow Rock Company, Invoice No. 9501, for $4,500 (cost is $2,000). I get the first part of the journal entry but don't know how to record the cost. May 3...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT