|
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. |
Here's my code so far
#include<stdio.h>
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, "\nMaking country %d's flag with width %d pixels...\n",country_code,width);
return(0);
}
#include<stdio.h>
#include<graphics.h>
#include<math.h>
int main()
{
int gd,gm;
int r,i,a,b,x,y,option;
float PI=3.14;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
printf("enter your option number..1,2,3");
scanf("%d",&option);
switch(option){
case 1:
printf("flag of Poland");
setcolor(WHITE);
rectangle(100,100,450,150);
setfillstyle(SOLID_FILL,WHITE);
floodfill(101,101,WHITE);
//draw the second rectangle and color it
setcolor(RED);
rectangle(100,150,450,200);
setfillstyle(SOLID_FILL,RED);
floodfill(101,151,RED);
break;
case 2:
printf("flag of Netherlands");
setcolor(RED);
rectangle(100,100,450,150);
setfillstyle(SOLID_FILL,RED);
floodfill(101,101,RED);
//draw the middle rectangle and color it
setcolor(WHITE);
rectangle(100,150,450,200);
setfillstyle(SOLID_FILL,WHITE);
floodfill(101,151,WHITE);
//draw the bottom rectangle and color it
setcolor(BLUE);
rectangle(100,200,450,250);
setfillstyle(SOLID_FILL,BLUE);
floodfill(101,201,BLUE);
break;
case 3:
printf("flag of Italy");
//draw the top rectangle and color it
setcolor(GREEN);
rectangle(400,400,150,150);
setfillstyle(SOLID_FILL,GREEN);
floodfill(101,201,GREEN);
//draw the middle rectangle and color it
setcolor(WHITE);
rectangle(400,450,150,100);
setfillstyle(SOLID_FILL,WHITE);
floodfill(101,151,WHITE);
//draw the bottom rectangle and color it
setcolor(RED);
rectangle(400,400,150,350);
setfillstyle(SOLID_FILL,RED);
floodfill(101,101,RED);
break;
default:
printf("choose proper option");
}
getch();
closegraph();
return 0;
}
Write a program called flags.c that is capable of creating an image of the flags of...
I want to create the flags for Poland, the Netherlands, and
Italy using ppm files and file redirection. I can't seem to get my
pixels lined up correctly to make my flags. Here's my output for
when I tried to make my flag for Poland. Any way to fix this?
I am working in C
#include #include <stdio.h> <stdlib.h> 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...
Your program should be capable of creating a ppm image of the flag of Benin • The new flag generated should use the proper width-to-height ratio as defined on Wikipedia for the flag. o For the colors, use pure red, and yellow, and a value of 170 for green. ▪ Pure color values are talked about in Lab 6. o The left green field should be 6/15ths of the width of the flag. Variables country_code should also include a new...
Read given code RaceOrNot3.c and write all possible outputs of the program. Assume there will be no thread creation or joining failures or semaphore failures. If you believe there is only one possible output, you just need to write that output. #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <semaphore.h> #include <errno.h> sem_t s1; int c=0,x=0; void *UpdateC1(void *arg) { int i; for(i=0;i<2000000;i++) { sem_wait(&s1); c++; x++; sem_post(&s1); } } void *UpdateC2(void *arg) { int i,x=0; for(i=0;i<2999999;i++) { sem_wait(&s1); c++; x++; ...
Read given code and write all possible outputs of the program. Assume there will be no thread creation or joining failures or mutex failures. If you believe there i only one possible output, you just need to write that output. Code: #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <semaphore.h> #include <errno.h> sem_t s1; int c[2] = {0,1}; void *UpdateC1(void *arg) { int i; for(i=0;i<1000000;i++) { sem_wait(&s1); c[0]=(c[0]+1)%2; c[1]=(c[1]+1)%2; sem_post(&s1); } return NULL; } void *UpdateC2(void *arg) { int i; for(i=0;i<2000000;i++)...
Read given code RaceOrNot1.c and write all possible outputs of the program. Assume there will be no thread creation or joining failures or mutex failures. If you believe there is only one possible output, you just need to write that output. #include <stdio.h> #include <stdlib.h> #include <pthread.h> pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t count_mutex3 = PTHREAD_MUTEX_INITIALIZER; int c[2] = {1,0}; void *UpdateC1(void *arg) { int i; for(i=0;i<1000000;i++) { pthread_mutex_lock(&count_mutex); c[0]=(c[0]+1)%2; c[1]=(c[1]+1)%2; pthread_mutex_unlock(&count_mutex); } return NULL; } void *UpdateC2(void *arg) { int...
Read given code RaceOrNot1.c and write all possible outputs of the program. Assume there will be no thread creation or joining failures or mutex failures. If you believe there is only one possible output, you just need to write that output. #include <stdio.h> #include <stdlib.h> #include <pthread.h> pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t count_mutex3 = PTHREAD_MUTEX_INITIALIZER; int c[2] = {1,0}; void *UpdateC1(void *arg) { int i; for(i=0;i<1000000;i++) { pthread_mutex_lock(&count_mutex); c[0]=(c[0]+1)%2; c[1]=(c[1]+1)%2; ...
Modify the programs so that each program can both receive and send
messages alternatively.
Note that when you run the two programs, you should run them in two different windows ( terminals). You should be able to send messages from one to the other and terminate them by entering "end" //msgl.cpp / Here's the receiver program. / #include #include #include #1nclude #include <stdlib.h> <stdio.h> <string.h> <errno.h> <unistd.h> #include <sys/types.h> #include <sys/ipc.h> Winclude <sys/msg.h> struct my msg st f long int...
I need to make it so this program outputs to an output.txt, the program works fine, just need it to fprintf to output.txt #include <stdio.h> #include <string.h> #include <malloc.h> #define MAX 30 struct treeNode { char names[MAX]; struct treeNode *right; struct treeNode *left; }*node; void searchName(char names[], struct treeNode ** parent, struct treeNode ** location) { struct treeNode * ptr, * tempPtr; if(node == NULL) { *location = NULL; *parent = NULL; return; } if(strcmp(names, node->names) == 0)...
Create another program that will prompt a user for input file. The user will choose from 4 choices: 1. Display all positive balance accounts. 2. Display all negative balance accounts. 3. Display all zero balance accounts. 4. End program. C PROGRAMMING my code so far #include<stdlib.h> #include<stdio.h> int main(void) { int request; int account; FILE *rptr; char name[20]; double balance; FILE *wptr; int accountNumber; if((wptr = fopen("clients.dat","w")) == NULL) { puts("File could not be opened"); } else {...
CORRECT THIS C PROGRAM FOR ME PLEASE. Suppose that at a particular steel mill, steel bars are grouped into classes according to their yield tensile strength as shown in the following table (note that this is not a standard classification): Class Tensile strength (MPa) ------------------------------------------------- A 1000.0 <= strength B 800.0 <= strength < 1000.0 C 600.0 <= strength < 800.0 D 400.0 <= strength < 600.0 E strength < 400.0 Write a program which reads a yield tensile strength...