You are here:   HomeC Programming (Theory)Control Structures in CWrite a C program to print all the ASCII values and their equivalent characters using a while loop. The ASCII values vary from 0 to 255.
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;

        clrscr();

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

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

             {

             printf("-");

             }

            getch();

}

 

       C program for Print a line of dashes



Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes 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.



What's New and Popular





Popular Article