Skip to main content

Search This Blog

matrix multiplication in c using functions and pointers

 #include <stdio.h> #define ROWS 3 #define COLS 3 void matrixMultiply(int *mat1, int *mat2, int *result, int rows1, int cols1, int cols2) {     int i, j, k;     // Multiplying matrices     for (i = 0; i < rows1; i++) {         for (j = 0; j < cols2; j++) {             *(result + i * cols2 + j) = 0;             for (k = 0; k < cols1; k++) {                 *(result + i * cols2 + j) += *(mat1 + i * cols1 + k) * *(mat2 + k * cols2 + j);             }         }     } } void displayMatrix(int *mat, int rows, int cols) {     int i, j;     // Displaying matrix     for (i = 0; i < rows; i++) {         for (j = 0; j < cols; j++) {             printf("%d\t", *(mat + i * cols + j)); ...

Sum of Two number java applet

Sum of Two number java applet

/* <applet code="sumOf2No" height=150 width =350>   </applet> */

import java.awt.*;

import java.applet.*;

publicclass sumOf2No extends Applet

{

     TextField T1,T2;

     publicvoid init() {

         T1 = new TextField(10);

         T2 = new TextField(10);

         add(T1);

         add(T2);

         T1.setText("0");

         T2.setText("0");

      }

      publicvoid paint(Graphics g) {

           int a, b, result;

           String str;

           g.drawString("Enter Number in TextField to Find addition of 2 No ",10,50);

           g.setColor(Color.red);

           str=T1.getText();

           a=Integer.parseInt(str);

           str=T2.getText();

           b=Integer.parseInt(str);

           result=a+b;

           g.drawString("After Addition the Result is : "+result,10,80);

           showStatus("Addition of 2 Numbers");

        }

public boolean action(Event e, Object o){

            repaint();

            returntrue;

        }

}


Comments

Contact Form

Name

Email *

Message *