Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    C Program to Print First 10 Natural Numbers

    C Programming Examples


    Natural numbers are the number of sequences of positive integers from 1 to infinity used to count and order.

    This C example code demonstrates a simple C program to calculate the first ten natural numbers and print the output to the screen. The primary purpose of this C program is to explain to beginners how loops work.

    Example:

    #include<stdio.h>
    
    void main() {
    
      int i; //Variable definition
    
      printf("The first 10 natural numbers are:\n ");
    
      for (i = 1; i <= 10; i++) //Iteration 10 times
      {
        printf("%d \t", i); //Print the number.
      }
    }
    

    Program Output:

    The first 10 natural numbers are:
     1      2       3       4       5       6       7       8       9       10


    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.