C Programming Examples Tutorial Index

C Loop Programs

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.



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