# 1 2 3 4 series Program in C

## Problem Analysis

1 2 3 4….n is a series of natural numbers. Natural numbers are used in counting and ordering. These are also known as “Cardinal Numbers” since they are used for counting. As these numbers are also used for ordering they are also called “Ordinal Numbers”.

The set of natural numbers is denoted by n.

## Problem Description

C program to print 1,2,3,4,…N can be developed using a for loop. Since a natural number has to be printed upto certain limit, the print statement has to be executed repeatedly. Repeated execution in C in language is possible with the help of for loop.

for variable is initialized with 1 and the condition for repeated execution is set by the user. By printing the value of the for loop variable we get the desired output.

## Solution to Problem

Following is the C program to print the series 1 2 3 4 ….N.

## 1 2 3 4 series program in C

```#include<stdio.h>
int main()
{
int p, N;
printf("Input value of N:");
scanf("%d", &N);

for(p=1; p<=N; p++)
{
printf("%d",p);
}
return 0;
}
```
```Output:

Input value of N:6

1   2   3   4   5   6
```
```Code Analysis

In the above code limit upto which natural numbers is to be printed is taken from user in user defined variable N. Code for this is:

printf("Input value of N:");
scanf("%d", &N);

N is used to set the terminating condition of the for loop. Series 1, 2, 3, 4, …, N is printed by placing printf statement inside the for loop. Code for this is:

for(p=1; p<=N; p++)
{
printf("%d   ",p);
}
```

## Conclusion

1 2 3 4 series program in C language use for loop to get desired output. Limit upto which the series has to be printed is set by the user.

Solution to problem section provides a program in C language to print series 1 2 3 4 … N.