by Dinesh Thakur Category: Control Structures

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;


        printf("Print a line of dashes :\n");

        for (i = 0; i < 50; i++)







       C program for Print a line of dashes

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles