#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]);
}
}
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?
Here's a simple Python program that constructs and displays a pyramid: def print_pyramid(height): for i in range(height): print(' ' * (height - i - 1) + '*' * (2 * i + 1)) print_pyramid(5) This code defines a function print_pyramid that takes the height of the pyramid as an argument and prints a pyramid made of asterisks (*). Adjust the height parameter in the print_pyramid function call to change the size of the pyramid.
write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program
You first learn how to program in C.
/* my second program in C++ with more comments */ #include <iostream> using namespace std; int main () { cout << "Hello World! "; // prints Hello World! cout << "I'm a C++ program"; // prints I'm a C++ program return 0; }
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?
Here's a simple Python program that constructs and displays a pyramid: def print_pyramid(height): for i in range(height): print(' ' * (height - i - 1) + '*' * (2 * i + 1)) print_pyramid(5) This code defines a function print_pyramid that takes the height of the pyramid as an argument and prints a pyramid made of asterisks (*). Adjust the height parameter in the print_pyramid function call to change the size of the pyramid.
write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program
A restaurant prints it out using a special program
ten
You first learn how to program in C.
/* my second program in C++ with more comments */ #include <iostream> using namespace std; int main () { cout << "Hello World! "; // prints Hello World! cout << "I'm a C++ program"; // prints I'm a C++ program return 0; }
Ask a local attorney.
reymond rillera reymond rillera
Your program is wrong.
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.
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 & 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.