---
# System prepended metadata

title: ‘’’ c

---

``` C=

p3
#include <stdio.h>
#include <stdbool.h>
 
 
int main()
{
  int mat[100][100];
  int k;
  bool uc = 0, lc = 0;
  scanf("%d", &k);
  for(int i = 1; i <= k; i++)
  {
    for(int j = 1; j <= k; j++)
    { 
      scanf("%d", &mat[i][j]);
    }
  }
  int check = (k) * (k-1) / 2; 
  int cnt = 0;
  for(int i = 1; i <= k; i++)
  {
    for(int j = 1; j < i; j++)
    {
      if(mat[i][j] == 0)
        cnt++;
    }
  }
  if(cnt == check)
    uc = 1;
  cnt = 0;
  for(int i = 1; i <= k; i++)
  {
    for(int j = k; j > i; j--)
    {
      if(mat[i][j] == 0)
        cnt++;
    }
  }
  if(cnt == check)
    lc = 1;
  if(lc && uc)
    printf("Diagonal Matrix\n");
  else if(lc)
    printf("Lower Triangular Matrix\n");
  else if(uc)
    printf("Upper Triangular Matrix\n");
  else
    printf("None Of Those\n");
  return 0;
}


p4

#include <stdio.h>
 
 
int main()
{
  int a[1000], b[1000] , sum[1000];
  for(int i = 1; i <= 15; i++)
    scanf("%d", &a[i]);
  for(int i = 1; i <= 15; i++)
    scanf("%d", &b[i]);
  int k = 0;
  for(int i = 15; i >= 1; i--)
  {
    sum[i] = (a[i] + b[i] + k) % 10;
    if(a[i] + b[i] + k >= 10)
     k = 1;
    else
     k = 0;
  }
  if(k == 1)
    sum[0] = 1;
  if(sum[0] == 1)
  {
    for(int i = 0; i <= 15; i++)
      printf("%d", sum[i]);
    printf("\n");
  }
  else
  {
    for(int i = 1; i <= 15; i++)
      printf("%d", sum[i]);
    printf("\n");
  }
  return 0;
}

p5

#include <stdio.h>
#include <stdbool.h>
 
int main()
{
  bool x[10];
  for(int i = 1; i <= 5; i++)
    x[i] = 0;
  int ans = 0;
  for(int i = 1; i <= 5; i++)
  {
    int k;
    scanf("%d", &k);
    x[k] = !x[k];
    int cnt = 0;
    for(int j = 1; j <= k; j++)
    {
      if(x[j] == 1) 
        cnt++;
    }
    if(cnt == k)
      ans++;
  }
  printf("%d\n",ans);
  return 0;
}
```