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)); ...

make a calculator in c or write a code calculator

 #include<stdio.h>

#include<conio.h>

int main(void)

{

float a,b;

char sign;

printf("Press 'q' to quit\n");

printf("Enter any number :");

scanf("%f",&a);

do{

printf("Enter any operator :");

scanf("%s",&sign);

printf("Enter any number :");

scanf("%f",&b);

switch(sign){

case'+':

a=a+b;

printf("Result :%.2Lf\n",a);

break;

case'-':

a=a-b;

printf("Result :%.2f\n",a);

break;

case'*':

a=a*b;

printf("Result :%.2f\n",a);

break;

case'/':

a=a/b;

printf("Result :%.2f\n",a);

break;

case'%':

a=(b*a)/100;

printf("Result :%.2f\n",a);

break;

default:

printf("Invalid Operator\n");

}

}

while(sign!='q');

printf("Thank you\n");

getch();

}


Comments

Contact Form

Name

Email *

Message *