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
Keep W3schools Growing with Your Support!
❤️ Support W3schools