|
| 1 | +import java.util.*; |
| 2 | +public class Main |
| 3 | +{ |
| 4 | + |
| 5 | + |
| 6 | + public static void main(String[] args){ |
| 7 | + Scanner sc = new Scanner(System.in); |
| 8 | + int m = sc.nextInt(); |
| 9 | + int n = sc.nextInt(); |
| 10 | + int fin_add = sum( m ,n); |
| 11 | + System.out.println(fin_add); |
| 12 | + } |
| 13 | + public static int sum(int a , int b){ |
| 14 | + int add = a+b; |
| 15 | + System.out.println(difference(a,b)); |
| 16 | + return add; |
| 17 | + } |
| 18 | + public static int difference(int a , int b){ |
| 19 | + int sub = a-b; |
| 20 | + return sub; |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +import java.util.*; |
| 28 | +public class Main |
| 29 | +{ |
| 30 | +public static void main(String[] args){ |
| 31 | + System.out.println("hello to main "); |
| 32 | + sumofnumbers(5); |
| 33 | + f1(); |
| 34 | + } |
| 35 | + |
| 36 | + public static void sumofnumbers(int n){ |
| 37 | + int sum =0; |
| 38 | + for(int i=1;i<=n;i++){ |
| 39 | + sum += i; |
| 40 | + } |
| 41 | + System.out.println(sum); |
| 42 | + return; |
| 43 | + } |
| 44 | + public static void f1(){ |
| 45 | + System.out.println("enter to f1"); |
| 46 | + int x = f2(); |
| 47 | + System.out.println(x); |
| 48 | + System.out.println("after executing f2"); |
| 49 | + } |
| 50 | + public static int f2(){ |
| 51 | + System.out.println("enter to f2"); |
| 52 | + f3(); |
| 53 | + System.out.println(" after executing f3"); |
| 54 | + return 5; |
| 55 | + } |
| 56 | + public static void f3(){ |
| 57 | + System.out.println("enter to f3 and return from where it calls"); |
| 58 | + } |
| 59 | + |
| 60 | + } |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + import java.util.*; |
| 66 | +public class Main{ |
| 67 | + |
| 68 | + |
| 69 | + public static void main(String[] args){ |
| 70 | + int a =5; |
| 71 | + a = increment(a); |
| 72 | + System.out.println(a); |
| 73 | + int []arr ={1,2,3,4,5}; |
| 74 | + System.out.println(Arrays.toString(arr)); |
| 75 | + |
| 76 | + arrayincrement(arr); |
| 77 | + System.out.println(Arrays.toString(arr)); |
| 78 | + for(int i=0;i<arr.length;i++){ |
| 79 | + System.out.println(arr[i]); |
| 80 | + } |
| 81 | + } |
| 82 | + public static int increment(int x){ |
| 83 | + x++; |
| 84 | + System.out.println(x); |
| 85 | + return x; |
| 86 | + } |
| 87 | + public static void arrayincrement(int x[]){ |
| 88 | + for(int i=0;i<x.length;i++){ |
| 89 | + x[i]++; |
| 90 | + } |
| 91 | + |
| 92 | + } |
| 93 | + |
| 94 | + |
| 95 | +} |
0 commit comments