Fill This Form To Receive Instant Help
Homework answers / question archive / Write the definition of a function dashedLine , with one parameter, an int
Write the definition of a function dashedLine , with one parameter, an int .
If the parameter is negative or zero, the function does nothing. Otherwise it prints a complete line terminated by a new line character to standard output consisting of dashes (hyphens) with the parameter's value determining the number of dashes. The function returns nothing.
Answer:
#import <iostream>
using namespace std;
void dashedLine(int);
int main()
{dashedLine(8);
dashedLine(0);
dashedLine(15);
dashedLine(-12);
system("pause");
return 0;
}
void dashedLine(int dashes)
{int i;
if(dashes>0)
{for(i=0;i<dashes;i++)
cout<<"-";
cout<<endl;
}
}