1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
import java.io.*; public class Saddle_Pnt { int min(int a[][], int r) { int i, min; min = a[r][0]; for(i=1;i < a[r].length;i++) { if(min>a[r][i]) min = a[r][i]; } return min; } int max(int a[][], int c) { int i, max; max = a[0][c]; for(i=1;i < a.length;i++) { if(max < a[i][c]) max = a[i][c]; } return max; } public static void main()throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int r, c; System.out.println("Enter the number of rows:"); r = Integer.parseInt(br.readLine()); System.out.println("Enter the number of columns:"); c = Integer.parseInt(br.readLine()); int a[][] = new int[r][c], i, j; Saddle_Pnt obb = new Saddle_Pnt(); System.out.println("Enter the values in the array:"); for(i=0;i < r;i++) { for(j=0;j < c;j++) { a[i][j] = Integer.parseInt(br.readLine()); } } for(i=0;i < r;i++) { for(j=0;j < c;j++) { if(obb.max(a, j)==a[i][j]&&obb.min(a,i)==a[i][j]) { System.out.println("The saddle point is at position: ("+i+", "+j+")"); return; } } } System.out.println("No Saddle point present"); } } |
Write A program to input two arrays A and B of different sizes taken from the user and print their product.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<h2>Output</h2> Enter the number of rows of the first matrix: 2 Enter the number of columns of the first matrix: 3 Enter the number of rows of the second matrix: 3 Enter the number of columns of the second matrix: 3 Enter the elements of the first array: 23 12 11 45 43 7 Enter the elements of second array: 32 16 98 9 5 6 4 1 10 The multiplied result: 888 439 2436 1855 942 4738 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
import java.io.*; public class matrix_mult { public static void main()throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); int m1, m2, n1, n2; System.out.println("Enter the number of rows of the first matrix:"); m1 = Integer.parseInt(r.readLine()); System.out.println("Enter the number of columns of the first matrix:"); n1 = Integer.parseInt(r.readLine()); System.out.println("Enter the number of rows of the second matrix:"); m2 = Integer.parseInt(r.readLine()); System.out.println("Enter the number of columns of the second matrix:"); n2 = Integer.parseInt(r.readLine()); if(n1!=m2) { System.out.println("Matrix multiplication not possible."); return; } int a[][] = new int[m1][n1], b[][] = new int[m2][n2], c[][]=new int[m1][n2]; int i, j, k, s=0; System.out.println("Enter the elements of the first array:"); for(i=0;i < m1;i++) { for(j=0;j < n1;j++) { a[i][j] = Integer.parseInt(r.readLine()); } } System.out.println("Enter the elements of second array:"); for(i=0;i < m2;i++) { for(j=0;j < n2;j++) { b[i][j] = Integer.parseInt(r.readLine()); } } for(i=0;i < m1;i++) { for(j=0;j < n2;j++) { s=0; for(k=0;k < m2;k++) { s = s+a[i][k]*b[k][j]; } c[i][j] = s; } } System.out.println("The product is:"); for(i=0;i < m1;i++) { for(j=0;j < n2;j++) { System.out.print(c[i][j]+"t"); } System.out.println(); } } } |
Write a program to input a matrix of size m by n and print the product obtained when multiplied by its transpose
Write a program to input a matrix of size m by n and print the product obtained when multiplied by its transpose
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<h2>Output</h2> Enter the number of rows: 2 Enter the number of columns: 3 Enter the values for the array: 12 21 11 13 54 23 Original Array: 12 21 11 13 54 23 Transpose Array: 12 13 21 54 11 23 Multiplied Array: 706 1543 1543 3614 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
import java.io.*; public class Transpose_Multiply { public static void main()throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); int m, n; System.out.println("Enter the number of rows:"); m = Integer.parseInt(r.readLine()); System.out.println("Enter the number of columns:"); n = Integer.parseInt(r.readLine()); int a[][] = new int[m][n], b[][] = new int[n][m], i, j, s=0, k; System.out.println("Enter the values for the array:"); for(i=0;i < m;i++) { for(j=0;j < n;j++) { //Taking the values of the array from the user a[i][j] = Integer.parseInt(r.readLine()); } } for(i=0;i < m;i++) { for(j=0;j < n;j++) { //Storing the transpose of the array in array B b[j][i] = a[i][j]; } } int c[][] = new int[m][m]; for(i=0;i < m;i++) { for(j=0;j < m;j++) { //Multiplying the two arrays using matrix //Multiplication rule s=0; for(k=0;k < n;k++) { s+=a[i][k]*b[k][j]; } c[i][j] = s; } } //Printing the various arrays System.out.println("Original Array:"); for(i=0;i < m;i++) { for(j=0;j < n;j++) { System.out.print(a[i][j]+"t"); } System.out.println(); } //Printing the various arrays System.out.println("Transpose Array:"); for(i=0;i < n;i++) { for(j=0;j < m;j++) { System.out.print(b[i][j]+"t"); } System.out.println(); } //Printing the various arrays System.out.println("Multiplied Array:"); for(i=0;i < m;i++) { for(j=0;j < m;j++) { System.out.print(c[i][j]+"t"); } System.out.println(); } } } |
Test On Organic Compound
ASPIRATION…DESIRE FOR SUCCESS CHEMISTRY – ORGANIC COMPOUND TIME 1 HR MARKS:30 Question-1 Name the following organic compounds : (i) (CH3)2C=CHC(C2H5)=CH2 (ii) (CH3)3CC?CCH2CH=C(CH3)2 (iii)HO2CCH2CH(CH2CH=CH2)CH2CH(C2H5)CO2H Question-2 Classify the following reaction as substitution, elimination, addition or condensation reactions and the nature of the reagent(electrophile or nucleophile) (a) Ethyl alcohol with concentrated sulphuric acid at 170oC. (b) […]
PHYSICS Mock Test On Section -B
PHYSICS MOCK TEST TIME 45MIN MARKS 30 Section –A (i) What kind of source produces a cylindrical wave front? (ii) On which factors does the deviation produced by a thin prism depend? (iii) A convex lens forms a virtual image of an object. Where is the object? Answer in terms of focal length. Section […]
Write a program to input two dates and print the number of days in between them.
Write a program to input two dates and print the number of days in between the two given dates. Assuming that the first date comes before the second
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<h2>Output</h2> Enter the first date: Enter the day: 24 Enter the month: 12 Enter the year: 2001 Enter the second date: Enter the day: 12 Enter the month: 6 Enter the year: 2006 There are 1631 days in between the two given dates |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
<h2>Program</h2> import java.util.*; public class date_days { boolean isvalid(int dd, int mm, int yy) { if(dd>31||dd<1||mm<1||mm>12||yy<1) return false; if((mm==4||mm==6||mm==9||mm==11)&&dd>30) return false; if(mm==2&&isleap(yy)&&dd>29) return false; if(mm==2&&!isleap(yy)&&dd>28) return false; return true; } boolean isleap(int yy) { if((yy%4==0&&yy%100!=0)||yy%400==0) return true; return false; } public void calculate() { Scanner sc = new Scanner(System.in); int d1, d2, m1, m2, y1, y2, i, c=0; System.out.println("Enter the first date:"); System.out.println("Enter the day:"); d1 = sc.nextInt(); System.out.println("Enter the month:"); m1 = sc.nextInt(); System.out.println("Enter the year:"); y1 = sc.nextInt(); System.out.println("Enter the second date:"); System.out.println("Enter the day:"); d2 = sc.nextInt(); System.out.println("Enter the month:"); m2 = sc.nextInt(); System.out.println("Enter the year:"); y2 = sc.nextInt(); if(!(isvalid(d1,m1,y1)&&isvalid(d2,m2,y2))) { System.out.println("The date is invalid."); return; } int dy[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, y; i=m1+1; y=y1; if(i>12) { i=1; y++; } if(m1==m2&&y1==y2) //if the month and the year are same. c = d2-d1; else { //When the month and year are different c = dy[m1-1]-d1+d2; while(true) { if(i==m2&&y==y2) break; if(isleap(y)) dy[1] = 29; else dy[1] = 28; c = c+dy[i-1]; i++; if(i>12) { i=1; y++; } } } if(c==1) System.out.println("There is "+c+" day in between the two given dates"); else System.out.println("There are "+c+" days in between the two given dates"); } public static void main() { date_days obj = new date_days(); obj.calculate(); } } |