Skip to main content

Problem Statement

Write a C program that takes a number N as input and prints all integers from 1 to N using a for loop.

Solution

#include <stdio.h>

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

Input

5

Output

1
2
3
4
5