C Program To Print First n Natural Numbers Using For Loop

C Program To Print First n Natural Numbers Using For Loop

Code
 // Print first n natural number using for loops.

#include <stdio.h>

int main()
{
    int n;
    printf("Enter number\n");
    scanf("%d", &n);
    for (int i = 0; i <= n; i++)
    {
        printf("%d\n", i);
    }

    return 0;
}
Output
Enter number
7
0
1
2
3
4
5
6
7

Post a Comment