The for loop given above prints a line of fifty dashes followed by a newline. The for loop uses i as the loop variable whose initial and final values are 0 and 49, respectively (note the < operator in i < 50). The update expression increments the value of i by 1.
Thus, the loop variable assumes values as 0, 1, 2, …, 49. For each value of i, the printf statement contained within the for loop prints a dash. Finally, the printf statement after the for loop prints a newline character to move the cursor to the next line.
#include <stdio.h>
void main()
{
int i;
clrscr();
printf(“Print a line of dashes :\n”);
for (i = 0; i < 50; i++)
{
printf(“-“);
}
getch();
}