Thanks in advance:
// File: main.cpp
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int recursiveCount = 0;
void triangle(const char drawChar, const int maxHeight, const int
currentHeight);
int main() {
char drawChar = '*';
recursiveCount = 0;
cout.fill(drawChar);
triangle(drawChar, 5, 1);
cout.fill(' ');
return 0;
}// end main()
void triangle(const char drawChar, const int maxHeight, const
int currentHeight) {
/* DO NOT edit code */
cout.fill(drawChar);
recursiveCount += 1;
/* END of do not edit */
/* TODO (1):
* Draw a right expanding triangle, using 'drawChar' as the
character.
* The maxHeight represents the final height of the triangle,
* whereas the currentHeight represents the height of each
side.
*/
}// end triangle()
Desired Output:
*
**
***
****
*****
****
***
**
*
If you have any doubts, please give me comment...
// File: main.cpp
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int recursiveCount = 0;
void triangle(const char drawChar, const int maxHeight, const int currentHeight);
int main() {
char drawChar = '*';
recursiveCount = 0;
cout.fill(drawChar);
triangle(drawChar, 5, 1);
cout.fill(' ');
return 0;
} // end main()
void triangle(const char drawChar, const int maxHeight, const int currentHeight) {
/* DO NOT edit code */
cout.fill(drawChar);
recursiveCount += 1;
/* END of do not edit */
/* TODO (1):
* Draw a right expanding triangle, using 'drawChar' as the character.
* The maxHeight represents the final height of the triangle,
* whereas the currentHeight represents the height of each side.
*/
if(currentHeight<=maxHeight){
cout<<setw(currentHeight)<<drawChar<<endl;
triangle(drawChar, maxHeight, currentHeight+1);
if(currentHeight!=maxHeight)
cout<<setw(currentHeight)<<drawChar<<endl;
}
} // end triangle()
Thanks in advance: // File: main.cpp #include <iostream> #include <fstream> #include <iomanip> using namespace std; int...
// File: main.cpp #include <iostream> #include <fstream> #include <iomanip> using namespace std; int recursiveCount = 0; void inorder(const int list[], const int n, const int index); int leftIndex(const int index); int rightIndex( const int index); int main() { int list[] = {1,2,3,4,5,6,7,8,9,10}; inorder(list, 10, 0); cout << endl; return 0; }// end main() void inorder(const int list[], const int n, const int index) { /* START - NO EDIT */ recursiveCount += 1; /* END - NO EDIT */ /*...
what is the output for the following code? explain the steps. /*#include <iostream> using namespace std; int f(int &i) { i = 10; return(5 * i); } int main() { int n = 5; f(n); cout << n << "\n"; return 0; } #include <iostream> using namespace std; int sub1(int n) { n--; return n; } int main() { int m = 10; for(int j = 0; j < 10; j++) m -= sub1(j); cout << m << "\n"; return...
#include <fstream> #include <iostream> #include <cstdlib> using namespace std; // Place charcnt prototype (declaration) here int charcnt(string filename, char ch); int main() { string filename; char ch; int chant = 0; cout << "Enter the name of the input file: "; cin >> filename; cout << endl; cout << "Enter a character: "; cin.ignore(); // ignores newline left in stream after previous input statement cin.get(ch); cout << endl; chcnt = charcnt(filename, ch); cout << "# of " «< ch« "'S:...
#include <iostream> using namespace std; void drawTriangle(int x) {} int main() {} Complete the program so that it produces a right-angle triangle of a user-specified height. For example: Enter a height for the triangle: 5 Result: * ** *** **** *****
//countingAnimals.cpp C++ #include <iostream> #include "Animal.h" using namespace std; int Animal::count = 0; int main(int argc, const char * argv[]) { Animal myAnimal; Animal anotherAnimal; cout << Animal::count << endl; return 0; }
#include <iostream> #include <vector> #include <iomanip> using namespace std; int main() { const int NUM_ITEMS = 8; vector <double> inverse(NUM_ITEMS); int j; double temp; for (int i = 0; i < NUM_ITEMS; i++) { inverse.at(i) = 1 / (i + 1.0); } cout << fixed << setprecision(2); cout << "Original vector..." << endl; for (int i = 0; i < NUM_ITEMS; i++) { cout << inverse.at(i) << " "; } cout << endl; cout << "Reversed vector..." << endl; for...
im not sure why my code isnt working? include <iostream> #include <iomanip> using namespace std; int main() { int amountOfCoffee; double Price; char salesTaxChargeability; double TotalAmount; const double SALESTAX = 0.035; // 3.5 % cout << "\nEnter the number of pounds of coffee ordered in Pounds :"; cin >> amountOfCoffee; cout << "\nEnter the price of coffee per Pound :"; cin >> Price; cout << "\nIs sales tax Chargeable (y or n): "; cin >> salesTaxChargeability; if ( (salesTaxChargeability ==...
So my test.h file has: #include <iostream> #include <fstream> using namespace std; class test { private: int data[]; public: test(string filename); }; My test.cpp file has: #include "sort.h" test::test(string filename) { ifstream inFile; inFile.open(filename); int iter = 0; while(!inFile.eof()) { cin >> data[iter]; iter++; } int numberOfNumbers = iter; for (iter = 0; iter < numberOfNumbers; iter++) cout << data[iter] << " "; ...
//main.cpp #include <iostream> #include <iomanip> #include "deck-of-cards.hpp" void RunAllTests() { int count; std::cin >> count; DeckOfCards myDeckOfCards; for (int i = 0; myDeckOfCards.moreCards() && i < count; ++i) { std::cout << std::left << std::setw(19) << myDeckOfCards.dealCard().toString(); if (i % 4 == 3) std::cout << std::endl; } } int main() { RunAllTests(); return 0; } //card.hpp #ifndef CARD_HPP_ #define CARD_HPP_ #include <string> class Card { public: static const int totalFaces = 13; static const int totalSuits = 4; Card(int cardFace, int...
Given the following code: #include <iostream> #include <iomanip> using namespace std; class Animal{ private: int height; int weight; public: void setHeight(int h){ height = h; } int getHeight(){ return height; } void setWeight(int w){ weight = w; } int getWeight(){ return weight; } virtual void makeSound() = 0; virtual void eat(); }; class Dog: public Animal{ public: void makeSound(){ cout << "Bow Bow\n"; } void eat (){ cout <<"The dog is eating\n"; } void Catch(){ cout << "The dog is...