Hey guys need some help, im a noob when it comes to c++ but im having an issue when it comes to 2 parameters in a function. Im trying to match my code with the sample output but having no luck and was wondering if anyone can guide me into what im doing wrong. thanks
// Demonstrates passing arguments to function parameters.
#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, 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.
*/
PrintLine(int howMany, int symbolToPrint);
cout << " Simple C++ Integer Types" << endl
<< " (Microsoft Specific)" << endl;
PrintLine(int howMany, int symbolToPrint);
<< "Data type Range" << endl;
PrintLine(int howMany, int symbolToPrint);
<< "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(int howMany, int 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)
// 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
*********************************************
*/[output]
thanks, i was looking into to but im still a little confused. once i declare my function which is PrintLine(int howMany, int symbolToPrint); and then i want to put in certain spots depending on if its * or - how would i set it up in output statements. thats where im confused
EDIT: so here is an update what i've done, I've managed to get the sample output but only with the * and not the dashes. Was wondering what ive done wrong and would greatly appreciate some help guys!
// Demonstrates passing arguments to function parameters.
#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, 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;
int symbolToPrint;
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
*********************************************
*/