#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],r,c;
for(r=0;r<=3;r++)
{
for(c=0;c<3;c++)
{
printf("\n enter the value=");
scanf("%d%d",&a[r][c],&b[r][c]);
}
}
printf("\n first matrix=\n");
for(r=0;r<=3;r++)
{
for(c=0;c<3;c++)
{
printf("%d\t",a[r][c]);
}
printf("\n");
}
printf("\n scond matrix=\n");
for(r=0;r<=3;r++)
{
for(c=0;c<3;c++)
{printf("%d\t",b[r][c]);
}
printf("\n");
}
printf("\n sum of given matrix=\n");
for(r=0;r<=3;r++)
{
for(c=0;c<3;c++)
{
c[r][c]=a[r][c]+b[r][c];
printf("%d\t",c[r][c]);
}
printf("\n");
}
getch();
}
#include
void main()
{
int mat[10][10];
int i,j;
int m,n;
int sumrow,sumcol;
cout<<\nenter the order of matrix;
cin>>m>>n;
cout<<\nenter elements of a matrix;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
cin>>mat[i][j];
}
for(i=0;i<m;i++)
{
sumrow=0;
for(j=0;j<n;j++)
sumrow=sumrow+mat[i][j];
cout<<"\n the sum of"<<i<<"row="<<sumrow;
}
for(j=0;j<n;j++)
{
sumcol=0;
for(i=0;i<m;i++)
sumcol=sumcol+mat[i][j];
cout<<\nthe sum of"<<j<<"column="<<sumcol;
}
#include <stdio.h>
main()
{
int a[5][5];
for (int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
a[i][j]=10+j+i;
}
}
for (int i=0;i<5;i++)
{
printf("%d\n",a[i][i]);
}
}
void main() { int arr1[3][3],arr2[3][3];
int i,j;
for(i=0;i<3;i++) //insertion of element of first array
{ for(j=0;j<3;j++)
{ scanf("%d",&arr1[i][j]);
}
}
for(i=0;i<3;i++) //elements of second array
{ for(j=0;j<3;j++)
{ scanf("%d",&arr2[i][j]);
}
}
for(i=0;i<3;i++) //addition
{ for(j=0;j<3;j++)
{ arr3[i][j]=arr1[i][j]+arr2[i][j];
}
}
for(i=0;i<3;i++) //output show
{ for(j=0;j<3;j++)
{ printf("%d",&arr[i][j]);
}
}
getch();
}
#include
#include
int main()
{
clrscr();
int A[10][10],m,n,x,y,sum=0;
//Create a Matrix A
cout << "Enter number of rows and columns in Matrix A : \n";
cin>>n>>m;
cout << "Enter elements of Matrix A : \n";
for(x=1;x
for(y=1;y
cin>>A[x][y];
//Find sum of each row
for(x=1;x
{
A[x][m+1]=0;
for(y=1;y
A[x][m+1]=A[x][m+1]+A[x][y];
}
//Find sum of each column
for(y=1;y
{
A[n+1][y]=0;
for(x=1;x
A[n+1][y]+=A[x][y];
}
cout << "\nMatrix A, Row Sum (Last Column)" << " and Column Sum (Last Row) :\n";
for(x=1;x
{
for(y=1;y
cout << A[x][y] << " ";
cout << "\n";
}
//Print sum of each column
x=n+1;
for(y=1;y
cout << A[x][y] << " ";
cout << "\n";
if(m==n)
{
for(x=1;x
for(y=1;y
if(x==y) sum+=A[x][y];
else if(y==m-(x+1)) sum+=A[x][y];
}
cout << "Sum of diagonal elements is : " << sum << endl;
getch();
return 0;
}
#include
#include
int main()
{
clrscr();
int A[10][10],m,n,x,y,sum=0;
//Create a Matrix A
cout << "Enter number of rows and columns in Matrix A : \n";
cin>>n>>m;
cout << "Enter elements of Matrix A : \n";
for(x=1;x
for(y=1;y
cin>>A[x][y];
//Find sum of each row
for(x=1;x
{
A[x][m+1]=0;
for(y=1;y
A[x][m+1]=A[x][m+1]+A[x][y];
}
//Find sum of each column
for(y=1;y
{
A[n+1][y]=0;
for(x=1;x
A[n+1][y]+=A[x][y];
}
cout << "\nMatrix A, Row Sum (Last Column)" << " and Column Sum (Last Row) : \n";
for(x=1;x
{
for(y=1;y
cout << A[x][y] << " "; cout << "\n"; }
//Print sum of each column x=n+1;
for(y=1;y
cout << A[x][y] << " "; cout << "\n";
if(m==n)
{
for(x=1;x
for(y=1;y
if(x==y) sum+=A[x][y];
else if(y==m-(x+1)) sum+=A[x][y];
}
cout << "Sum of diagonal elements is : " << sum << endl;
getch();
return 0;
}
To find the sum of the diagonals of a given matrix the following code fragment can be used (with suitable definitions and data initialisations):
if (num_rows > num_cols) max = num_cols;
else max = num_rows;
sum = 0;
for (i = 0; i < max; i++) sum += matrix[i][i];
printf("Sum of diagonal elements is %d\n", sum);
#include
int main()
{
int a,b,c;
Yes, please do.
This is a directive, not a question.
//the following code will help you to write the program for(i=n-1, j=0; i > 0; i--, j++) //n is the order of the square matrix { for(k=j; k < i; k++) printf("%d ", a[j][k]); for(k=j; k < i; k++) printf("%d ", a[k][i]); for(k=i; k > j; k--) printf("%d ", a[i][k]); for(k=i; k > j; k--) printf("%d ", a[k][j]); } m= (n-1)/2; //calculate the position of the middle element if (n% 2 == 1) printf("%d", a[m][m]);//to print the middle element also //9809752937(udanesh)
Yes but why.
echo 'print a pattern'
If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).
This is a directive, not a question.
http://www.assignmentsclub.com/
how do you erase dot matrix print form paper
A basic dot matrix has 9 pins, which produces an average print. A dot matrix with 24 pins (or more) will produce a better quality print.
dot matrix
//the following code will help you to write the program for(i=n-1, j=0; i > 0; i--, j++) //n is the order of the square matrix { for(k=j; k < i; k++) printf("%d ", a[j][k]); for(k=j; k < i; k++) printf("%d ", a[k][i]); for(k=i; k > j; k--) printf("%d ", a[i][k]); for(k=i; k > j; k--) printf("%d ", a[k][j]); } m= (n-1)/2; //calculate the position of the middle element if (n% 2 == 1) printf("%d", a[m][m]);//to print the middle element also //9809752937(udanesh)
Yes but why.
#include <stdio.h> #include <conio.h> void main() { int d[3][3] = { 1, 2, 6, 3, 8, 5, 5, 6, 7 }; int k = 0, j = 0; int sum1 = 0, sum2 = 0; for (j = 0; j < 3; j++) { for (k = 0; k < 3; k++) printf(" %3d", d[j][k]); printf("\n"); } for (j = 0; j < 3; j++) { sum1 = sum1 + d[j][j]; } k = 3 - 1; for (j = 0; j < 3; j++) { if (k >= 0) { sum2 = sum2 + d[j][k]; k--; } } printf("Sum of First diagonal= %d\n", sum1); printf("Sum of Second diagonal= %d", sum2); getch();
A line printer and dot matrix printer differ in how they print pages. Line printers are more commonly used with computers, while dot matrix printers function similarly to a typewriter.PrintingA line printer print pages exactly as its name implies, one line at a time. Dot matrix printers use pins arranged in a matrix that physically strike an ink ribbon between the pin and the paper to print characters.SpeedLine matrix printers can print roughly 1,200 lines per minute, or generally about 20 pages per minute. Dot matrix printers print about 40-300 characters per second, or about six to seven pager per minute, at best.QualityDot matrix printers have a lower print quality than line printers. The characters' shapes on pages printed using a dot matrix printer appear as a number of dots connected together. Line printers print solid characters and can use a wide variety of font face and sizes.
echo 'print a pattern'
If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).
write a program to print A to Z on screen in c?