Question about Intel Computers & Internet

1 Answer

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

1 Answer

  • 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
  • 201 Answers

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

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

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

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

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


Source code:

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

May 19, 2011 | Computers & Internet

1 Answer

I WANT THE WHOLE CODE FOR THIS


This whole code for above we can not give.

Aug 06, 2009 | Shopnovell iFolder 1.0 Software Media Kit...

1 Answer

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;
}BITMAPFILEHEADER;
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;
} BITMAPINFOHEADER;
typedef struct tagRGBQUAD {
char rgbRed;
char rgbGreen;
char rgbBlue;
char rgbRserved;
} RGBQUAD;
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[256];
}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;
BITMAPFILEHEADER bheader;
BITMAPINFO binfo;
char color, huge *buff;
long rest, width, i, j, k;
clrscr();
bmpfile=fopen("my.bmp", "rb");
// read info
fread(&bheader, sizeof(bheader), 1, bmpfile);
fread(&binfo, sizeof(binfo), 1, bmpfile);
fseek(bmpfile, bheader.bfOffbits, 0);
// picture width score
if(rest=binfo.bmiHeader.biWidth % 4)
width = binfo.bmiHeader.biWidth+ 4-rest;
else
width = binfo.bmiHeader.biWidth;
// from file to array (64K==MAX)
buff=(char far *)farmalloc(binfo.bmiHeader.biHeight*width);
k=0;
for(j=0; j<binfo.bmiHeader.biHeight; j++)
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(j=binfo.bmiHeader.biHeight; j>0; j--)
for(int i=0; i<width; i++){
putpixel(i, j, buff[k++]);
}
getch();
closegraph();

fclose(bmpfile);
}
Rate me please.

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

1 Answer

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

5 Answers

Source code for stack using arrays in c++


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

Dec 05, 2008 | Computers & Internet

3 Answers

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

1 Answer

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

1 Answer

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

3 Answers

C programming coading


1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Apr 30, 2008 | Computers & Internet

Not finding what you are looking for?
Computers & Internet Logo

Related Topics:

259 people viewed this question

Ask a Question

Usually answered in minutes!

Top Intel Computers & Internet Experts

Tony

Level 3 Expert

2600 Answers

David
David

Level 3 Expert

778 Answers

vsri9

Level 2 Expert

73 Answers

Are you an Intel Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...