my code stock.com

columnas

Snippet options

Download: Download snippet as programa-38.c.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

#include<stdio.h>
#include<windows.h>
void leermatriz();
void imprimirmatriz();
void sumafilas();
void sumacolumnas();
int fila, columna,i,j;
int matriz[50][50];
int sumafila[50],sumacolumna[50];
int main()
{
	printf("\nPrograma 38 que sume los elementos de las filas de una matriz cuadrada");
	leermatriz();
	imprimirmatriz();
	sumafilas();
	sumacolumnas();
	}
void leermatriz()
{
	printf("\nLectura de matriz");
	do{printf("\nDame la cantidad de fila=>");
	scanf("%d",&fila);
	printf("Dame la cantidad de columnas=>");
	scanf("%d",&columna);
	if(fila!=columna)
	{
		printf("\nNumero de filas debe ser igual al de columnas");
	}
	}while(fila!=columna);
	for(j=0;j<fila;j++){
		sumafila[j]=0;
	}
	for(j=0;j<columna;j++){
		sumacolumna[j]=0;
	}
	for(i=0;i<fila;i++){
		for(j=0;j<columna;j++){
			printf("\nDame el valor de la casilla[%d][%d]",i,j);
			scanf("%d",&matriz[i][j]);
			if(i==((fila-1)/(2))){
		    sumafila[i]=sumafila[i]+matriz[i][j];
			}
		}
		if(j==((columna-1)/(2))){
			sumacolumna[j]=sumacolumna[j]+matriz[i][j];}
	}
	system("pause");
	return;
}
void imprimirmatriz()
{
	printf("\nMatriz");
	for(i=0;i<fila;i++){
		printf("\n");
		for(j=0;j<columna;j++){
			printf("\t%d",matriz[i][j]);
		}
	}
	system("pause");
	return;
}
void sumafilas()
{
	printf("\nSuma de las filas");
	for(i=0;i<fila;i++)
	{
			if(i==((fila-1)/(2))){
	printf("\nLa suma es:%d",sumafila[i]);}	
	}
	
	system("Pause");
	return;
}
void sumacolumnas()
{
	printf("\nSuma de las columnas");
	for(i=0;i<columna;i++){
		
		printf("\nLa suma es:%d",sumacolumna[i]);}	
	
	
	system("pause");
	return;
}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.