Page 388 - CA_Blue( J )_Class10
P. 388
11 { System.out.print("Enter a number : ");
12 ar[i][j] =sc.nextInt();
13 }
14 }
15 for (i=0; i<2; i++)
16 { for(j=0;j<3;j++)
17 {
18 f=1;
19 for(k=1;k<=ar[i][j];k++)
20 {
21 f=f*k;
22 }
23 System.out.println("The factorial of "+ar[i][j]+" : "+f);
24 }
25 }
26 }
27 }
You will get the following output:
Enter a number : 1
Enter a number : 2
Enter a number : 3
Enter a number : 4
Enter a number : 5
Enter a number : 6
The factorial of 1 : 1
The factorial of 2 : 2
The factorial of 3 : 6
The factorial of 4 : 24
The factorial of 5 : 120
The factorial of 6 : 720
Program 8 To input elements in an 2d array of size m x n and print the sum of all the number row wise.
1 import java.util.*;
2 class array_double_sum
3 { public static void main()
4 { Scanner sc= new Scanner(System.in);
386386 Touchpad Computer Applications-X

