#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)); } printf("\n"); } } int main() { int mat1[ROWS][COLS] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int mat2[ROWS][COLS] = {{9, 8, 7}, {6, 5, 4}, {
what is programming language
You must appreciate the fact that programming languages are created by us humans. These languages are used to communicate instructions to machines, especially computers, so that programs can control the behavior of the machines' hardware to achieve the desired results. Basically, the hardware of the computer understands only the language of the hardware which is called as machine language. The hardware is unable to understand and understand a program written in another programming language. In addition, each type of CPU has its own machine language. Therefore, in order for the computer's hardware to understand the instructions contained in a program written in another programming language, a mechanism is needed, called a 'translator'. It converts programs written in programming languages other than the native machine language of the CPU (hardware) into the native machine language of a particular CPU on which this program is intended to be executed. Each programming language must have its own translator for the programs written in it to be executed or run on computer hardware. The different types of translators available can be classified into assembler, interpreter or compiler.
The primitive or first generation of programming languages were called machine languages and symbols like '0' and '1' were used to write programs under this category of programming languages. The second generation of programming languages was called assembly language and mainly used mnemonics to create programs. Both these generations of programming languages were CPU dependent i.e. each type of CPU would have its own machine and assembly language.
The third generation of programming languages were called high level languages because these programming languages were independent of the CPU of the hardware being used and the instructions written in the programs were similar to the instructions given in natural languages. The third generation languages are known as 3GL languages. The current generation of programming languages is called the fourth generation language or 4GL. These languages represent the class of programming languages that are closest to human (natural) languages.
Comments
Post a Comment