We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent beda62b commit 5c5ed0fCopy full SHA for 5c5ed0f
Test7_Natural_Number_sum.java
@@ -0,0 +1,36 @@
1
+package com.test.Basic_Java_Programs;
2
+
3
+import java.util.Scanner;
4
5
+public class Test7_Natural_Number_sum
6
+{
7
+ public static void main(String[] args)
8
+ {
9
+ int n, sum = 0;
10
11
+ System.out.print("Enter Number :");
12
13
+ Scanner sc = new Scanner(System.in);
14
15
+ n = sc.nextInt();
16
17
+ for (int i = 1; i <= n; i++)
18
19
+ sum = sum + i;
20
21
+ }
22
+ System.out.print("Addition "+ sum);
23
24
25
+}
26
27
28
+/* Output:
29
30
31
+ Enter Number : 10
32
+Addition 55
33
34
35
36
+ */
0 commit comments