In c++, print the RGB values of the American flag (withoutthe stars). If the RGB values were to be written to a ppm file,when you double click the file, an image like this should bedisplayed.The structure of the flag alternates between red and white stripeswith a blue box on the left. The skeleton code that contains thedimensions are already given.In the main function, output to the terminal the PPM Header withppm file type, Width, Height, and Maximum value for each colorlike:P3171 90255Then write a nested for loop to create the structure of the flagwith RPG values of:Blue: 10 49 97Red: 179 25 66White: 255 255 255Create a program that takes an integer from user input and outputsthe correct RGB values (pixels) to the terminal.Sample run:Enter height of each stripe in pixels (integer):1
P324 1325510 49 97 10 49 97 10 49 97 10 49 97 10 49 97 10 49 97 10 49 97 1049 97 10 49 97 179 25 66 179 25 66 179 25 66 179 25 66 179 25 66179 25 66 179 25 66 179 25 66 179 25 66 179 25 66 179 25 66 179 2566 179 25 66 179 25 66 179 25 66 10 49 97 10 49 97 10 49 97....
Given code:
#include <iostream>#include <fstream>using namespace std;int main() { // 13 stripes in the flag int stripes = 13; int h_stripe; cout << "Enter height of each stripe in pixels(integer):" << endl; cin >> h_stripe; int h = stripes * h_stripe; // Assume eachstripe would be h_stripe pixels in height int w = h * 1.9; // Actual flagproportions // Union dimensions (round to nearest int) thedimension of the blue section int union_w = 0.4 * w; //TODO: Write the PGM file header //TODO: Write a nested for loop logic to print theflag for(){ for(){ } cout <<endl; }}
In c++, print the RGB values of the American flag (without the stars). If the RGB values were to be written to a ppm fi
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am