Write the definition of a function dashedline, with one parameter, an int. If th
ID: 3798661 • Letter: W
Question
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 reruns nothing. ( please use C standard) 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 reruns nothing. ( please use C standard)Explanation / Answer
#include <stdio.h>
void dashedline(int);
int main() {
int a1,b;
printf("Enter the value");
scanf("%d ",&a1);
b=a1;
dashedline(b);
return 0;
}
void dashedline(int a)
{
if(a>0)
{ int i;
for(i=0;i<a;i++)
{ printf("%c ", '-');
}
printf(" ");
}
}
In this C code, when we enter the positive value it returns dashed lines according to the entered number. If the entered value is negative or zero, it return nothing. This will get the required output for the mentioned program.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.