Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

Print Numbers from 1 to N using a For Loop.

#include <stdio.h>

int main() {
int N;

// Taking input for N
printf(“Enter a positive integer N: “);
scanf(“%d”, &N);

// Printing numbers from 1 to N using a for loop
for (int i = 1; i <= N; i++) {
printf(“%d “, i);
}

return 0;
}