All articles
c

A program to print numbers between 1 and 10 (explain FOR)

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 036

The following code shows how to write a program to print numbers between 1 and 10 (explain FOR).

Program

#include <stdio.h>
 
void main()
{
    int i;
 
    printf("Numbers below 10 are \n");
    for (i = 1; i <= 10; i++)
    {
        printf("%d\n", i);
    }
 
    printf("\n");
}

Result

Numbers below 10 are
1
2
3
4
5
6
7
8
9
10

Comments