Question about Intel Computers & Internet

# I have problem in how to call the matrix using fuction

#include #include
#include
void matrix(int *a[2][2],int *b[2][2],int *c[2][2]);
main()
{
int a[2][2]={{3,3},{4,4}};
int b[2][2]={{1,1},{2,2}},c[2][2],i,j;
matrix(&a[2][2],&b[2][2],&c[2][2]);
printf("product of 2 matrix is");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
printf(" %d",c[i][j]);
printf(" ");
}
}
void matrix(int *a[2][2],int *b[2][2],int *c[2][2])
{
int x=*a;
int y=*b;
int z=*c;
int i,j,sum=0;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
sum=sum+(x*y);
z=sum;
}
}

Posted by on

• Level 2:

An expert who has achieved level 2 by getting 100 points

MVP:

An expert that gotĀ 5 achievements.

Vice President:

An expert whose answer gotĀ voted for 100 times.

Champion:

An expert who has answered 200 questions.

• Expert

I don think u are in the right way to program the Matrix in C language, i found a lot of syntax error in your code, but nevermind i had correct it for u. Maybe still need a little correction for your own. Following code:

void matrix(int a[2][2],int b[2][2],int c[2][2]);
main()
{
int a[2][2]={{3,3},{4,4}};
int b[2][2]={{1,1},{2,2}};
int c[2][2]={0},i,j;
matrix(a,b,c);
printf("product of 2 matrix is");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
printf(" %d",c[i][j]);
printf(" ");
}
}
void matrix(int a[2][2],int b[2][2],int c[2][2])
{
int row,col,sum1=0,sum2=0;
for(col=0;col<2;col++)
{
row=0;
sum1=(a[row][col]*b[row][col])+(a[row][col]*b[row+1][col]);
c[row][col]=sum1;
sum2=(a[row+1][col]*b[row][col])+(a[row+1][col]*b[row+1][col]);
c[row+1][col]=sum2;
}
}

Posted on Sep 10, 2009

## 1 Suggested Answer

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

×

my-video-file.mp4

Complete. Click "Add" to insert your video.

×

## Related Questions:

### Source code for implementation of linked list using opengl in vc++

Source code:

#include
using namespace std;
{
private:
struct node
{
int data;
}*p;
public:
void append( int num );
void add_as_first( int num );
void addafter( int c, int num );
void del( int num );
void display();
int count();
};
{
p=NULL;
}
{
node *q,*t;
if( p == NULL )
{
p = new node;
p->data = num;
}
else
{
q = p;
while( q->link != NULL )
t = new node;
t->data = num;
}
}
{
node *q;
q = new node;
q->data = num;
p = q;
}
{
node *q,*t;
int i;
for(i=0,q=p;i {
if( q == NULL )
{
cout return;
}
}
t = new node;
t->data = num;
}
void linklist::del( int num )
{
node *q,*r;
q = p;
if( q->data == num )
{
delete q;
return;
}
r = q;
while( q!=NULL )
{
if( q->data == num )
{
delete q;
return;
}
r = q;
}
cout}
{
node *q;
cout for( q = p ; q != NULL ; q = q->link )
coutdata;
}
{
node *q;
int c=0;
for( q=p ; q != NULL ; q = q->link )
c++;
return c;
}
{
node *q;
if( p == NULL )
return;
while( p != NULL )
{
delete p;
p = q;
}
}
int main()
{
cout ll.append(12);
ll.append(13);
ll.append(23);
ll.append(43);
ll.append(44);
ll.append(50);
ll.display();
cout ll.del(333);
ll.del(12);
ll.del(98);
cout return 0;
}

May 19, 2011 | Computers & Internet

### Texture mapping problem

Here:
#include<stdio.h>
#include<conio.h>
#include <graphics.h>
#include <stdlib.h>
#include <alloc.h>
///////////////////////////////////////////////// BMP format structures
typedef struct tagBITMAPFILEHEADER {
int bfType;
long bfSize;
int bfReserved1;
int bfReserved2;
long bfOffbits;
typedef struct tagBITMAPINFOHEADER {
long biSize;
long biWidth;
long biHeight;
int biPlanes;
int biBitCount;
long biCompression;
long biSizeImage;
long biXPelsPerMeter;
long biYPelPerMeter;
long biClrUsed;
long biClrImportant;
typedef struct tagRGBQUAD {
char rgbRed;
char rgbGreen;
char rgbBlue;
char rgbRserved;
typedef struct tagBITMAPINFO {
}BITMAPINFO;
///////////////////////////////////////////////// SVGA256 set functions
int huge p(void) { return(2); }
void setvideo()
{ int gdriver,gmode;
// gdriver=installuserdriver("svga256",p);
gdriver=DETECT;
initgraph(&gdriver,&gmode,"c:\\minc\\bgi");
}
///////////////////////////////////////////////// MAIN
void main(){
FILE *bmpfile;
BITMAPINFO binfo;
char color, huge *buff;
long rest, width, i, j, k;
clrscr();
bmpfile=fopen("my.bmp", "rb");
fread(&binfo, sizeof(binfo), 1, bmpfile);
// picture width score
width = binfo.bmiHeader.biWidth+ 4-rest;
else
// from file to array (64K==MAX)
k=0;
for(int i=0; i<width; i++){
fread(&color, sizeof(color), 1, bmpfile);
buff[k++]=color;
}

setvideo();
// set palette
for(i=0; i<256;i++)
setrgbpalette(i, binfo.bmiColors[i].rgbBlue>>2,
binfo.bmiColors[i].rgbGreen>>2,
binfo.bmiColors[i].rgbRed>>2
);
// drowing
k=0;
for(int i=0; i<width; i++){
putpixel(i, j, buff[k++]);
}
getch();
closegraph();

fclose(bmpfile);
}

May 17, 2009 | Microsoft Visual Studio 2005 Standard...

### How to make program of finfing the determinant of m*n matrix in C coding

I solve your problem but there is a little mistake that I can't find but maybe you can so here what I wrote:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <math.h>

#define n 3

typedef struct
{
double A[n][n];
int size;
}Matrix;

double det(Matrix mat);
Matrix cut(Matrix mat, int x);
int main(void)
{
clrscr();
double d;
Matrix mat;
mat.size=n;
mat.A[0][0]=1;
mat.A[0][1]=2;
mat.A[0][2]=3;
mat.A[1][0]=4;
mat.A[1][1]=4;
mat.A[1][2]=6;
mat.A[2][0]=7;
mat.A[2][1]=8;
mat.A[2][2]=9;

d=det(mat);
printf("%d",d);
getch();
return 0;
}
double det(Matrix mat)
{
double d=0;
if(mat.size>2)

for(int i=0;i<mat.size;i++)

d+=pow(-1,i)*mat.A[0][i]*det(cut(mat,i));

else

d=mat.A[0][0]*mat.A[1][1]-mat.A[0][1]*mat.A[1][0];

return d;
}
Matrix cut(Matrix mat, int x)
{
Matrix cutmat;
cutmat.size=mat.size-1;
for(int i=0;i<cutmat.size;i++)
for(int j=0;j<cutmat.size;j++)
if(j<x)
cutmat.A[i][j]=mat.A[i+1][j];
else
cutmat.A[i][j]=mat.A[i+1][j+1];
return cutmat;
}
Rate me if it helped!
And if you find the mistake please tell me where thanks.

Mar 06, 2009 | Intel Computers & Internet

### Source code for stack using arrays in c++

stack in c using arrays
/* Program of stack using array*/
#include

Dec 05, 2008 | Computers & Internet

### I need solve this type calulation is 0,1,1,2,3,5,8,13,21,34 etc. u send me the code of this type of calculation in c++ language

Ok! Here's a snippit from some code I wrote in beginning c++ classes. However, don't just cut and paste it. Know how it works since it's important in algorithm examination!

Just tested it, compiles and runs perfectly on GCC 4.0.1 on my mac, as well as my linux boxen. Windows may take some changes to output data.

/***********************************************
* Steven Parker
* Calculating Fib Sequence
* after two starting values, each number is the
* sum of the two preceding numbers
***********************************************/
#include <iostream>
using namespace std;

int main() {
int whentostop = 20; //How many values of sequence to calculate
int fib[whentostop]; //Hold fib numbers

for (int i=0; i < whentostop; i++) {
if (i == 0)
fib[0] = 0;
else if (i == 1)
fib[1] = 1;
else
fib[i] = fib[i-1] + fib[i-2];

cout << "Fibonacci[" << i << "]: " << fib[i] << endl;
}
return 0;
}

Nov 12, 2008 | Computers & Internet

### C code

try this Code

1. #include<stdio.h>
2. #include<conio.h>
3. #include<alloc.h>
4. void main()
5. {
6. int i, j,n,*p,check=1, blank, memspace, mem=0, rowdiff=1;
7. printf("Enter the no. of rows to be printed :");
8. scanf("%d",&n);
9. blank=n-1;
10. memspace=((n*(n+1))/2);
11. p=(int*)malloc(sizeof(int)* memspace);
12. for(i=0;i<n;i++)
13. {
14. printf("\n");
15. for(j=0;j<blank;j++)
16. printf(" ");
17. for(j=0;j<check;j++)
18. {
19. if(j==0 || j==(check-1))
20. p[mem]=1;
21. else
22. p[mem]=p[mem-rowdiff] + p[mem-rowdiff+1];
23. printf("%d ",p[mem]);
24. mem++;
25. }
26. for(j=0;j<blank;j++)
27. printf(" ");
28. blank--;
29. check++;
30. rowdiff++;
31. }
32. getch();
33. }
--------------------------------------------------------------------------------------------------------------------------------------------------
#include<stdio.h>
void main()
{
int num,x,y,a[50][50];
clrscr();
fflush(stdin);

printf("Enter the number of rows: ");
scanf("%d",&num);

printf("\n\t\tPascal's Triangle of Order %d\n\n",num);

for(x=0;x<num;x++)
{
for(y=0;y<=x;y++)
{
if(x==y || y==0)
a[x][y]=1;
else
a[x][y]=a[x-1][y-1]+a[x-1][y];
printf("%4d",a[x][y]);
}
printf("\n\n");
}

getch();
}

Sep 20, 2008 | Computers & Internet

### Need code

Try the Following Five Programs

1) Program for Prime Number Generation

#include <stdio.h>
main()
{
int n,i=1,j,c;
clrscr();
printf("Enter Number Of Terms
");
printf("Prime Numbers Are Follwing
");
scanf("%d",&n);
while(i<=n)
{
c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
c++;
}
if(c==2)
printf("%d ",i)
i++;
}
getch();
}
--------------------------------------------------------------------------------------------------------------------------------------------------

2)Program for finding the prime numbers

#include <stdio.h>
#include <conio.h>
void main()
{
int n,m,k,i,max;
char c;
clrscr();
repeat: max=0;
k=2;
n=1;
printf("You want prime numbers upto:- ");
scanf("%d",&max);
printf("

");
for (i=1;i<=max;i++)
{
again: m=(n/k)*k;
if (m!=n)
k=k+1;
else
goto try1;
if (k < n/2)
goto again;
else
printf("%d",n);
printf(" ");
try1: n=n+1;
k=2;
}
fflush(stdin);
printf ("

Do you want to continue?(y/n):- ");
scanf("%c",&c);
if (c=='y')
goto repeat;
getch();

}
---------------------------------------------------------------------------------------------------------------------------------------------------

3)
1. #include <stdio.h>
2. int main(void) {
3. int n,
4. lcv,
5. flag; /* flag initially is 1 and becomes 0 if we determine that n
6. is not a prime */
7. printf("Enter value of N > ");
8. scanf("%d", &n);
9. for (lcv=2, flag=1; lcv <= (n / 2); lcv++) {
10. if ((n % lcv) == 0) {
11. if (flag)
12. printf("The non-trivial factors of %d are: \n", n);
13. flag = 0;
14. printf("\t%d\n", lcv);
15. }
16. }
17. if (flag)
18. printf("%d is prime\n", n);
19. }
---------------------------------------------------------------------------------------------------------------------------------------------------

4)

#include<stdio.h>

#include<conio.h>

void main()

{

int n,i,c=0;

clrscr();

printf("enter the number:");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

if(n%i==0)

{

c=c+1;

}

}

if(c==2)

printf("number is prime");

else

printf("number is not prime");

getch();

}
-------------------------------------------------------------------------

5)
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter the number:");
scanf("%d",&a);
for(b=2;b<a/2;b++)
{
if(n%i==0)
{
printf("\n Its not a Prime number");
c=1;
break;
}
if(flag==0)
printf("\n Its a Prime Number");
getch();
}
}

Sep 02, 2008 | Computers & Internet

## Open Questions:

#### Related Topics:

259 people viewed this question

## Ask a Question

Usually answered in minutes!

Level 3 Expert

Level 3 Expert