#include <stdio.h>

   int Diagonal_P(int vetor[]){
       return vetor[0]+vetor[4]+vetor[8];
   }
   int Diagonal_S(int vetor[]){
       return vetor[2]+vetor[4]+vetor[6];
   }

   int main() {
   int vetor[9];
   for(int i=0; i<9; i++){
       scanf("%d", &vetor[i]);
   }
   printf("Diagonal principal: %d",Diagonal_P(vetor));
   printf("\nDiagonal secundaria: %d", Diagonal_S(vetor));
   return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: