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 trouble with my do while loop. I'm trying to get it where if the...
I'm having trouble with my do while loop. I'm trying to get it where if the user enter's 3 after whatever amount of caffeinated beverages they've entered before then the loop will close and the rest of my code would proceed to execute and calculate the average price of all the caffeinated beverages entered. Can someone please help me with this? Here's my Code: import java.util.Scanner; public class Main { public static void main(String[] args) { CaffeinatedBeverage[] inventory = new...
I'm having trouble with this program here's the problem: A milk carton can hold 3.78 liters...
I'm having trouble with this program here's the problem: A milk carton can hold 3.78 liters of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one liter of milk is $0.38, and the profit of each carton of milk is $0.27. Write a program that does the following: Prompts the user to enter the total amount of milk produced in liters. Outputs the number of milk cartons needed to...
I'm trying to explain in simple terms what the weak interaction does, but I'm having trouble...
I'm trying to explain in simple terms what the weak interaction does, but I'm having trouble since it doesn't resemble other forces he's familiar with and I haven't been able to come up (or find on the web) with a good, simple visualization for it.
C# Arrays & methods I'm having trouble implementing the GetIntArrayFromUser method in the following problem: Create...
C# Arrays & methods I'm having trouble implementing the GetIntArrayFromUser method in the following problem: Create a method AverageIntArray that takes an array of integers and calculates and returns the average of all values in the array as a double Write a program that uses GetIntArrayFromUser method to get an array of 7 numbers, then calls the AverageIntArray method to get the average then prints all values in the array that are greater than the average.                 Sample run:                                ...
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 am having trouble with a C++ code that I'm working on. It is a spell...
I am having trouble with a C++ code that I'm working on. It is a spell checker program. It needs to compare two arrays, a dictionary, and an array with misspelled strings that are compared to the strings in the dictionary. the strings that are in the second array that is not in the Dictionary are assumed to be misspelled. All of the strings in the dictionary are lowercase without any extra characters so the strings that are passed into...
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...
I'm having a bit of an issue with one of my C++ labs. It's not for...
I'm having a bit of an issue with one of my C++ labs. It's not for score but I need to understand it so I can move on. A restaurant servers burgers for $8 and salads for $7. When the customer selects a burger they must choose if they would like cheese. If they do, cheddar costs an additional 25 cents while pepper jack is 50 cents. When the customer selects a salad they must choose if they would like...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT