We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c5c05c2 commit ca10dbbCopy full SHA for ca10dbb
print n natural numbers
@@ -0,0 +1,28 @@
1
+/**
2
+ * C program to print all natural numbers from 1 to n
3
+ */
4
+
5
+#include <stdio.h>
6
7
+int main()
8
+{
9
+ int i, n;
10
11
+ /* Input upper limit from user */
12
+ printf("Enter any number: ");
13
+ scanf("%d", &n);
14
15
+ printf("Natural numbers from 1 to %d : \n", n);
16
17
+ /*
18
+ * Start loop counter from 1 (i=1) and go till n (i<=n)
19
+ * increment the loop count by 1 to get the next value.
20
+ * For each repetition print the value of i.
21
22
+ for(i=1; i<=n; i++)
23
+ {
24
+ printf("%d\n", i);
25
+ }
26
27
+ return 0;
28
+}
0 commit comments