Matrix
Title
Question
#include <stdio.h>
int main()
{
int rowCount, columnCount, i, j;
int firstMatrix[10][10], secondMatrix[10][10], resultMatrix[10][10];
printf("Number of rows of matrices to be subtracted : ");
scanf("%d", &rowCount);
printf("Number of columns matrices to be subtracted : ");
scanf("%d", &columnCount);
printf("Elements of first matrix : \n");
for (i = 0; i < rowCount; i++)
for (j = 0; j < columnCount; j++)
scanf("%d", &firstMatrix[i][j]);
printf("Elements of second matrix : \n");
for (i = 0; i < rowCount; i++)
for (j = 0; j < columnCount; j++)
scanf("%d", &secondMatrix[i][j]);
printf("Difference of entered matrices : \n");
for (i = 0; i < rowCount; i++)
{
for (j = 0; j < columnCount; j++)
{
resultMatrix[i][j] = firstMatrix[i][j] - secondMatrix[i][j];
printf("%d\t",resultMatrix[i][j]);
}
printf("\n");
}
return 0;
}
By
N.L.Pooja
Ece department
IRTT
C-and-Cpp Loops 04-05 min 50-60 sec
Answers:
Assignments are only for self-assessment. If you have any specific question related to this tutorial please post here.
Program in c to print 0 to 9 using for loop:
int main()
{
int x = 0;
for(x;(x<10);x++)
{
printf("%d\n",x);
}
return 0;
}
Output:
0
1
2
3
4
5
6
7
8
9
Program in cpp to print 0 to 9 using for loop:
#include <iostream>
using namespace std;
int main()
{
int x = 0;
for(x;(x<10);x++)
{
cout<<x<<"\n";
}
return 0;
}
Output:
0
1
2
3
4
5
6
7
8
9
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
for(i=o;i<10;i++)
{
printf("%d",i);
}
}
output:
0
1
2
3
4
5
6
7
8
9
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
for(i=0;i<10i++)
{
printf("i");
}
return 0;
}
output:
0
1
2
3
4
5
6
7
8
9
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
for(i=0;i<10i++)
{
printf("i");
}
return 0;
}
output:
0
1
2
3
4
5
6
7
8
9
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
for(i=o;i<10;i++)
{
printf("%d",i);
}
}
output:
0
1
2
3
4
5
6
7
8
9
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
for(i=0;i<=10;i++)
{
printf("%d",i);
}
}
output:
0
1
2
4
5
6
7
8
9
#include<stdio.h>
#include<conio.h>
int main()
{
int i;
for(i=0;i<10i++)
{
printf("i");
}
return 0;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
for(i=0;i<10;i++)
{
printf("%d\n",i);
}
getch();
}
putput
0
1
2
3
4
5
6
7
8
9
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
for(i=0;i<10;i++)
{
printf("%d\n",i);
}
getch();
}
putput
0
1
2
3
4
5
6
7
8
9
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
for(i=0;i<10;i++)
{
printf("%d\n",i);
}
getch();
}
putput
0
1
2
3
4
5
6
7
8
9
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
for(i=0;i<10;i++)
{
printf("%d\n",i);
}
getch();
}
output:
0
1
2
3
4
5
6
7
8
9
Login to add comment