answersLogoWhite

0


Best Answer

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

void draw_x(int width, int height);

int main(int argc, char *argv[]){

int width, height;

if(argc != 3){

printf("Syntax: this_program width height\n");

exit(1);

}

width = atoi(argv[1]);

height = atoi(argv[2]);

// make sure they're both positive non-zeros

if(height > 0 && width > 0){

draw_x(width, height);

}else{

printf("numbers must be naturals\n");

exit(1);

}

return 0;

}

void draw_x(int width, int height){

int tally = 0;

int drawx, drawy;

char grid[height][width + 1];

memset(grid, ' ', height * (width + 1) * sizeof(char));

if(width > height){

drawy = 0;

for(drawx = 0; drawx < width; drawx++){

tally += height;

if(tally > width){

tally -= width;

drawy++;

}

grid[drawy][drawx] = '*';

grid[drawy][width - drawx - 1] = '*';

}

}else{

drawx = 0;

for(drawy = 0; drawy < height; drawy++){

tally += width;

if(tally > height){

tally -= height;

drawx++;

}

grid[drawy][drawx] = '*';

grid[drawy][width - drawx - 1] = '*';

}

}

for(drawy = 0; drawy < height; drawy++){

grid[drawy][width] = 0;

printf("%s\n", grid[drawy]);

}

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program that prints the letter X composed of asterisks?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a program that input a positive integer and prints a triangle using for loop?

write a program that reads in the size of the side of square and then pints a hollow square of that size out of asterisks and blanks?


Write a program that read phrase and print the number of lower-case letter in it using function of counting?

write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program


How did menu's develop?

A restaurant prints it out using a special program


Create a program which accepts a number not less than 10The program prints the reverse of the number?

ten


How do you write a c program that prints a box an oval an arrow and a diamond?

You first learn how to program in C.


Dry run table in flow-chart?

/* my second program in C++ with more comments */ #include &lt;iostream&gt; using namespace std; int main () { cout &lt;&lt; "Hello World! "; // prints Hello World! cout &lt;&lt; "I'm a C++ program"; // prints I'm a C++ program return 0; }


How do you write a letter for remove your finger prints?

Ask a local attorney.


Program in c to develop an algorithm that prints the n value of algorithm?

reymond rillera reymond rillera


Why MsgBox with string 000 prints e but 00 or 0000 are printed correctly Thank you ozcansyahoocom?

Your program is wrong.


How mailmerge works?

Mail-merge - Is the creation of a standard letter, designed to be sent to many people. for example, you might want to invite all the members of a film club to an annual general meeting. Using a mail-merge program (most word-processors have them built-in) - You would type the main letter, and create a separate name &amp; address list. The mail-merge program then combines the letter with the list, and prints out as many copies of the letter as there are addresses. Each copy of the letter will have a different persons details on it.


Do a program with turbo pascal to print the alphabet backward?

Turbo Pascal is a style of computer programming. This type of writing language can be used to create a program that prints the alphabet backwards.


How do you write a c program to prints name?

Write a c program that reads your first name and surname when you enter them. Each part of your name should not be more than 12 characters. Finally, have the program display your full name.