please help me with my homework, I am having trouble executing my code correctly . I managed to do everything properly except I'm not sure how to alternate between "*" and "-" as the sample output is asking its doing *'s and then -'s on every line. tried figuring this out for hours and still can't. probably simple. but I've been trying harder than needed. thanks in advance.
// Demonstrates passing arguments to function parameters.
#include <iostream>
#include <iomanip>
usingnamespace std;
// TODO: Write function prototype here. This function should be:
// Name: PrintLine
// Parameter(s): howMany & symbolToPrint (use appropriate data types)
// Returns: <nothing>
void PrintLine(int howMany, int symbolToPrint);
//-----------------------------------------------------------------------------
int main()
{
/* TODO: Call (invoke) the function where necessary to
produce output as shown in sample (below).
NOTE: You will need to break-up this long output
statement into at least 3 separate output statements.
*/
int howMany=0;
int symbolToPrint=0;
PrintLine(howMany, symbolToPrint);
cout << endl;
cout << " Simple C++ Integer Types" << endl
<< " (Microsoft Specific)" << endl;
PrintLine(howMany, symbolToPrint);
cout << endl;
cout << "Data type Range" << endl;
PrintLine(howMany, symbolToPrint);
cout << endl;
cout << "char: " << setw(20) << CHAR_MIN << " to " << CHAR_MAX << endl
<< "short:" << setw(20) << SHRT_MIN << " to " << SHRT_MAX << endl
<< "int: " << setw(20) << INT_MIN << " to " << INT_MAX << endl
<< "long: " << setw(20) << LONG_MIN << " to " << LONG_MAX << endl;
PrintLine(howMany, symbolToPrint);
cout << endl;
return 0;
}
//-----------------------------------------------------------------------------
// TODO: Write the PrintLine function definition here
// Be sure that the function heading matches the prototype above
void PrintLine(int howMany, int symbolToPrint)
{
for (int howMany = 1; howMany <= 45; howMany++)
{
cout << '*';
}
for (int symbolToPrint = 1; symbolToPrint <= 45; symbolToPrint++)
{
cout << '-';
}
}
// PrintLine()
// prints symbolToPrint repeatedly (as defined by howMany) on one line
//-----------------------------------------------------------------------------
/* Sample program output:
*********************************************
Simple C++ Integer Types
(Microsoft Specific)
----------------------------------------
Data type Range
----------------------------------------
char: -128 to 127
short: -32768 to 32767
int: -2147483648 to 2147483647
long: -2147483648 to 2147483647
*********************************************
*/
ok so I managed to make some progress with the coding after just checking back in. I found a way to make the * and - read but now im having trouble with writing the printline function definition as it keeps saying function void printline(int, char) already has a body. which I can see at the top but im trying to figure out why it asks for the pl function to be defined at the bottom when I already have at the beginning , I just tried anything / to change it hoping it would work in this example but it hasn't, please help me understand
#include <iostream>
#include <iomanip>
using namespace std;
// TODO: Write function prototype here. This function should be:
// Name: PrintLine
// Parameter(s): howMany & symbolToPrint (use appropriate data types)
// Returns: <nothing>
void PrintLine(int howMany, char symbolToPrint)
{
for (int i = 1; i <= howMany; i++)
{
cout << symbolToPrint;
}
cout << endl;
}
//-----------------------------------------------------------------------------
int main()
{
/* TODO: Call (invoke) the function where necessary to
produce output as shown in sample (below).
NOTE: You will need to break-up this long output
statement into at least 3 separate output statements.
*/
PrintLine(45, '*');
cout << " Simple C++ Integer Types" << endl;
cout << " (Microsoft Specific)" << endl;
PrintLine(40, '-');
cout << "Data type Range" << endl;
PrintLine(40, '-');
cout << "char: " << setw(20) << CHAR_MIN << " to " << CHAR_MAX << endl;
cout << "short:" << setw(20) << SHRT_MIN << " to " << SHRT_MAX << endl;
cout << "int: " << setw(20) << INT_MIN << " to " << INT_MAX << endl;
cout << "long: " << setw(20) << LONG_MIN << " to " << LONG_MAX << endl;
PrintLine(45, '*');
return 0;
}
//-----------------------------------------------------------------------------
// TODO: Write the PrintLine function definition here
// Be sure that the function heading matches the prototype above
void PrintLine(int n, char symbol)
{
for (int i = 0; i < n; i++)
{
printf("%c", symbol);
}
printf("\n");
}