Skip to main content

Write a java program for multiplying two matrices and print the product for the same | VCMIT

Two matrices and print the product for the same.


INPUT

public class Matrix1{
public static void main(String args[]){   
int a[][]={{1,1,1},{2,2,2},{3,3,3}}; 
int b[][]={{1,1,1},{2,2,2},{3,3,3}};     
int c[][]=new int[3][3];   
for(int i=0;i<3;i++){ 
for(int j=0;j<3;j++){ 
c[i][j]=0;   
for(int k=0;k<3;k++)   
{   
c[i][j]+=a[i][k]*b[k][j];   
}
System.out.print(c[i][j]+" "); 
}
System.out.println(); 

}}

OUTPUT



Comments

Popular posts from this blog

Create House Like Structure Perform Operations Program In C | VCMIT

Program to create a house like figure and perform the following operations.  Scaling about the origin followed by translation.  Scaling with reference to an arbitrary point. Reflect about the line y = mx + c. INPUT #include <stdio.h> #include <graphics.h> #include <stdlib.h> #include <math.h> #include <conio.h> void reset (int h[][2]) { int val[9][2] = { { 50, 50 },{ 75, 50 },{ 75, 75 },{ 100, 75 }, { 100, 50 },{ 125, 50 },{ 125, 100 },{ 87, 125 },{ 50, 100 } }; int i; for (i=0; i<9; i++) { h[i][0] = val[i][0]-50; h[i][1] = val[i][1]-50; } } void draw (int h[][2]) { int i; setlinestyle (DOTTED_LINE, 0, 1); line (320, 0, 320, 480); line (0, 240, 640, 240); setlinestyle (SOLID_LINE, 0, 1); for (i=0; i<8; i++) line (320+h[i][0], 240-h[i][1], 320+h[i+1][0], 240-h[i+1][1]); line (320+h[0][0], 240-h[0][1], 320+h[8][0], 240-h[8][1]); } void rotate (int h[][2], float angle) { int i; for (i=0; i<9; i++) { int xnew, ynew; xnew = h[i][0] * cos (angl...

Software Engineering - Spiral Model | VCMIT

Spiral Model The spiral model, initially proposed by Boehm, is an evolutionary software process model that couples the iterative feature of prototyping with the controlled and systematic aspects of the linear sequential model. It implements the potential for rapid development of new versions of the software. Using the spiral model, the software is developed in a series of incremental releases. During the early iterations, the additional release may be a paper model or prototype. During later iterations, more and more complete versions of the engineered system are produced. Each cycle in the spiral is divided into four parts: Objective setting: Each cycle in the spiral starts with the identification of purpose for that cycle, the various alternatives that are possible for achieving the targets, and the constraints that exists. Risk Assessment and reduction: The next phase in the cycle is to calculate these various alternatives based on the goals and constraints. The focus of evaluation ...

Drawing Different Shapes Program In C | BGI | VCMIT

Drawing Different Shapes Program In C INPUT #include<graphics.h> #include<conio.h> main() {    int gd = DETECT,gm,left=100,top=100,right=200,bottom=200,x= 300,y=150,radius=50;    initgraph(&gd, &gm, "C:\\TC\\BGI");    rectangle(left, top, right, bottom);    circle(x, y, radius);    bar(left + 300, top, right + 300, bottom);    line(left - 10, top + 150, left + 410, top + 150);    ellipse(x, y + 200, 0, 360, 100, 50);    outtextxy(left + 100, top + 325, "My first C graphics program");    getch();    closegraph();    return 0; } OUTPUT