[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 379: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 678: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 678: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/session.php on line 1042: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
DOEACC FORUM • View topic - Project:- Sum of Matrix

Project:- Sum of Matrix

Learn and Trouble Shoot Problems Related to C-Language here.

Project:- Sum of Matrix

Unread postby rajeevmahura » Thu May 22, 2008 6:05 pm

/* Program For Sum of Two Matrix */
#include<stdio.h>
#include<conio.h>
void main()
{
int data1[5][5],data2[5][5],sum[5][5];
int cho,i,j,r,c;
clrscr();
printf("Enter Rows of Matrix:- ");
scanf("%d",&r);
printf("\nEnter Columns of Matrix:- ");
scanf("%d",&c);
for(i=1;i<=r;i++)
{
for(j=1;j<=c;j++)
{
printf("Enter The First Matrix Element [%d][%d] ",i,j);
scanf("%d",&data1[i][j]);
}
}
for(i=1;i<=r;i++)
{
for(j=1;j<=c;j++)
{
printf("Enter The Second Matrix Element [%d][%d] ",i,j);
scanf("%d",&data2[i][j]);

sum[i][j]=data1[i][j]+data2[i][j];
}
}
printf("\nSum of Matrix \n\n");
for(i=1;i<=r;i++)
{
for(j=1;j<=c;j++)
{
printf("%d ",sum[i][j]);
}
printf("\n");
}
getch();
}




-----------------------------------------------------------------------------

Input:- Enter Row of Matrix:- 2
Enter Columns of Matrix:- 2
Enter The First Matrix Element [1][1] 1
Enter The First Matrix Element [1][2] 2
Enter The First Matrix Element [2][1] 3
Enter The First Matrix Element [2][2] 4
Enter The Second Matrix Element [1][1] 2
Enter The Second Matrix Element [1][2] 4
Enter The Second Matrix Element [2][1] 6
Enter The Second Matrix Element [2][2] 8

Output:- Sum of Matrix

3 6
9 12
--Regards--
Rajeev Mahura
Servers & Storage Professional
http://about.me/rajeevmahura
User avatar
rajeevmahura
 
Posts: 144
Joined: Tue May 20, 2008 5:22 pm
Location: Bangalore | New Delhi
Full Name:
Date Of Birth: 15 Jan 1984
Address:
Profession: DOEACC Trainer
DOEACC Center: DOEACC DELHI
Mobile No: 0

Return to C-Language

Who is online

Users browsing this forum: No registered users and 1 guest

cron