Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

I need the output in my program to look like the white image But instead I am getting this output: This is my code: #include

I need the output in my program to look like the white image
But instead I am getting this output:
This is my code:
#include "TriangularVertices.h"
#include
#include
void TriangularVertices::printTriangle(int rows){
for (int i =1; i = rows; ++i){
printSpacesBefore(rows, i);
printNumbersRow(i);
std::cout std::endl;
if (i != rows){
printSpacesBefore(rows, i);
printSlashesRow(i);
std::cout std::endl;
}
}
}
void TriangularVertices::printNumbersRow(int row){
int startNumber = calculateStartNumber(row);
for (int i =0; i row; ++i){
std::cout std::setw(2) startNumber + i;
if (i row -1) std::cout "";
}
}
void TriangularVertices::printSlashesRow(int row){
std::cout std::setw(1); // Minor adjustment to slash alignment
for (int i =0; i row; ++i){
std::cout "/\\";
}
}
void TriangularVertices::printSpacesBefore(int totalRows, int currentRow){
int spaces =(totalRows - currentRow)*2;
for (int i =0; i spaces; ++i){
std::cout "";
}
}
int TriangularVertices::calculateStartNumber(int row){
return row *(row -1)/2+1;
}
What part of the code am I doing wrong and how can I fix it?
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started