my code stock.com

Snippet options

Download: Download snippet as periferia.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 suma();
int main()
{
	system("Color 4b");
	printf("\nPrograma que imprima la suma de la periferia de una matriz");
	leermatriz();
	imprimirmatriz();
	suma();
	}
void leermatriz()
{
	int matriz[50][50];
	int fila, columna,i,j;
	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(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]);
			}
	}
	system("pause");
	
}
void imprimirmatriz()
{
	int matriz[50][50];
	int fila, columna,i,j;
	for(i=0;i<fila;i++){
		printf("\n");
		for(j=0;j<columna;j++){
			system("color d");
			printf("\t%d",matriz[i][j]);
		}
	}
	system("pause");
	
}void suma()
{
	int matriz[50][50];
	int fila,columna,i,j;
	int sumaperiferia=0;
	for(i=0;i<=fila-1;i++){
		for(j=0;j<=columna-1;j++){
			if(i==0||i==fila-1||j==0||j==columna-1){
				sumaperiferia+=matriz[i][j];
				printf("\nLa suma de los elementos de la periferia es:%d",sumaperiferia);
			}
		}
	}
	printf("\nLa suma de los elementos de la periferia es:%d",sumaperiferia);
system("pause");

}

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.