File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package AllDailyPractice ;
2+
3+ import java .util .Scanner ;
4+
5+ public class AddTwoMatrix {
6+
7+ public static void main (String [] args ) {
8+
9+ int m , n , i , j ;
10+ Scanner sc = new Scanner (System .in );
11+
12+ System .out .println ("Enter the number of rows and columns of matrix" );
13+ m = sc .nextInt ();
14+ n = sc .nextInt ();
15+
16+ int first [][] = new int [m ][n ];
17+ int second [][] = new int [m ][n ];
18+ int sum [][] = new int [m ][n ];
19+
20+ System .out .println ("Enter the elements of first matrix" );
21+
22+ for ( i = 0 ; i < m ; i ++ )
23+ for ( j = 0 ; j < n ; j ++ )
24+ first [i ][j ] = sc .nextInt ();
25+
26+ System .out .println ("Enter the elements of second matrix" );
27+
28+ for ( i = 0 ; i < m ; i ++ )
29+ for ( j = 0 ; j < n ; j ++ )
30+ second [i ][j ] = sc .nextInt ();
31+
32+ for ( i = 0 ; i < m ; i ++ )
33+ for ( j = 0 ; j < n ; j ++ )
34+ sum [i ][j ] = first [i ][j ] + second [i ][j ];
35+
36+ System .out .println ("Sum of entered matrices:-" );
37+
38+ for ( i = 0 ; i < m ; i ++ )
39+ {
40+ for ( j = 0 ; j < n ; j ++ )
41+ System .out .print (sum [i ][j ]+"\t " );
42+
43+ System .out .println ();
44+
45+ }
46+ }
47+ }
Original file line number Diff line number Diff line change 1+ package AllDailyPractice ;
2+
3+ public class AddTwoNoInJava8 {
4+
5+ public static void main (String [] args ) {
6+ int x =10 ;
7+ int y =15 ;
8+ int c = x +y ;
9+ System .out .println ("Addition of two no is " +c );
10+
11+ }
12+
13+ }
Original file line number Diff line number Diff line change 1+ package AllDailyPractice ;
2+
3+ import java .util .Scanner ;
4+
5+ public class ArmstrongNumber {
6+
7+ public static void main (String [] args ) {
8+
9+ int arm =0 ;
10+ int a =0 ;
11+
12+ Scanner sc = new Scanner (System .in );
13+ System .out .println ("Enter any number" );
14+ int n = sc .nextInt ();
15+ int d =n ;
16+ while (n >0 ) {
17+ a = n %10 ;
18+ arm = arm +a *a *a ;
19+ n =n /10 ;
20+ }
21+ if (d ==arm ) {
22+ System .out .println ("Number is Armstrong" );
23+ }else {
24+ System .out .println ("Number is not Armstrong" );
25+ }
26+
27+
28+
29+
30+ }
31+
32+ }
You can’t perform that action at this time.
0 commit comments