158k views
0 votes
Compile and run this program so that you understand its effect.

Write a similar program that prints a large letter C on the screen
using only symbolic constants.

User Martin AJ
by
7.9k points

1 Answer

4 votes

Final answer:

To print a large letter C on the screen using only symbolic constants, you can define the C shape using characters and assign them to different rows and columns in an array. This program creates a 5x5 array called C, where empty spaces are represented by the character ' ' and asterisks are represented by the character '*'. It then uses nested loops to iterate over the array and print each character.

Step-by-step explanation:

To print a large letter C on the screen using only symbolic constants, you can define the C shape using characters and assign them to different rows and columns in an array. Here's how you can do it in C++:

#include<iostream>

using namespace std;

int main() {

char C[5][5] = {

{' ', ' ', '*', '*', ' '},

{' ', '*', ' ', ' ', ' '},

{'*', ' ', ' ', ' ', ' '},

{'*', ' ', ' ', ' ', ' '},

{' ', '*', ' ', ' ', ' '}

};

for (int i = 0; i < 5; i++) {

for (int j = 0; j < 5; j++) {

cout << C[i][j];

}

cout << endl;

}

return 0;

}

This program creates a 5x5 array called C, where empty spaces are represented by the character ' ' and asterisks are represented by the character '*'. It then uses nested loops to iterate over the array and print each character. Running this program will display a large letter C on the screen.

User Edmund Schweppe
by
8.4k points