
- Forum
- Programming Talk
- C and C++
- .multiply two 4*4 integer matrics
.multiply two 4*4 integer matrics
This is a discussion on .multiply two 4*4 integer matrics within the C and C++ forums, part of the Programming Talk category; . can any one help me to do this multiply two 4*4 integer matrics .swap two numbers without using a ...
-
11-19-2009, 10:35 AM #1
.multiply two 4*4 integer matrics
. can any one help me to do this
multiply two 4*4 integer matrics
.swap two numbers without using a third variable
.read details of 10 students(name,roll no:,score)
sort the student record with score ,and print it
-
03-01-2010, 04:44 AM #2
Give your code .If it is any problem in that code I will help.
-
07-02-2010, 05:30 AM #3
- Join Date
- Jul 2010
- Answers
- 7
code in c++
#include<iostream.h>
void main()
{
int a[4][4],b[4][4],m[4][4];
cout<<"\nEnter I matrix elements\n";
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
cin>>a[i][j];
}
}
cout<<"\nEnter II matrix elements\n";
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
cin>>b[i][j];
}
}
}
cout<<"\nMultiplied matrix\n";
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
m[i][j]=0;
for(k=0;k<4;k++)
{
m[i][j]=m[i][j]+a[i][k]*b[k][j];
}
}
}
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
cout<<m[i][j]<<" ";
}
cout<<"\n";
}
}
-
08-15-2010, 11:39 AM #4
- Join Date
- Aug 2010
- Answers
- 1
Answers for swapping and student record...
1) Swap two numbers without using a third variable
Let 2 numbers be p and q
p=p+q
q=p-q
p=p-q
2) Read details of 10 students(name, roll no:, score) and sort the student record with score, and print it
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct Student
{
char name[15];
int rollno,score;
};
void main()
{
struct Student s[4];
int i,j,t_rollno,t_score;
char t_name[15];
clrscr();
printf("\nEnter the Records of students: ");
for(i=0;i<4;i++)
{
printf("\nEnter the details of Student %d",i+1);
printf("\nName: ");
scanf("%s",s[i].name);
printf("RollNo: ");
scanf("%d",&s[i].rollno);
printf("Score: ");
scanf("%d",&s[i].score);
}
for(i=0;i<3;i++)
{
for(j=i+1;j<4;j++)
{
if(s[i].score < s[j].score)
{
strcpy(t_name,s[i].name);
t_rollno = s[i].rollno;
t_score = s[i].score;
strcpy(s[i].name,s[j].name);
s[i].rollno = s[j].rollno;
s[i].score = s[j].score;
strcpy(s[j].name,t_name);
s[j].rollno = t_rollno;
s[j].score = t_score;
}
}
}
printf("\nList of students arranged according to the grade\n");
for(i=0;i<4;i++)
{
printf("%d. Name: %s\t",i+1,s[i].name);
printf("RollNo: %d\t",s[i].rollno);
printf("Score: %d\n",s[i].score);
}
getch();
}
-
09-23-2010, 11:52 AM #5
- Join Date
- Sep 2010
- Answers
- 2
#include<stdio.h>
#include<conio.h>
void main()
{ clrscr();
int i,j,m,n;
int a[4][4];
int b[4][4];
int temp[4][4];
printf("enter element in 4*4 array A");
for(i=1;i<=4;i++){ // shows no. of column
for(j=1;j<=4;j++){ // shows no. of rows
scanf("%d",&a[i][j]);
}
}
printf("enter element in 4*4 array B");
for(m=1;m<=4;m++){ // shows no. of column
for(n=1;n<=4;n++){ // shows no. of rows
scanf("%d",&b[m][n]);
}
}
printf("multiplication of A and B is :");
for(i=1;i<=4;i++){
for(m=1;m<=4;m++){
temp[i][m]=0;
for(j=1;j<=4;j++){
temp[i][m]= temp[i][m]+a[i][j]*b[j][m];
}
}
}
for(i=1;i<=4;i++){
for(j=1;j<=4;j++){
printf("%d",&temp[i][j]);
printf(" ");
}
printf("\n");
}
/* for(i=1;i<=4;i++){
for(j=1;j<=4;j++){
printf("%d",a[i][j]);
}
}*/
getch();
}
Last edited by admin; 09-24-2010 at 09:24 AM.
-
Sponsored Ads

Reply With Quote






