C Program for loop: "Print 1 to N number using for loop" with output

 #include <stdio.h>

int main() { int N; // Input N printf("Enter a number N: "); scanf("%d", &N); // Check if N is positive if (N < 1) { printf("N should be a positive integer.\n"); return 1; } // Print numbers from 1 to N printf("Numbers from 1 to %d are:\n", N); for (int i = 1; i <= N; i++) { printf("%d\n", i); } return 0; }





Enter a number N: 5 Numbers from 1 to 5 are: 1 2 3 4 5

Comments

Popular posts from this blog

Video Formats

Where video editing is used

File saving and folder management