# Input numbers in 2d array and find the sum of all 2 digit and 3 digit numbers in C

###### Two Dimensional Array - Question 2

In this question, we will see how to input numbers in a 3X3 integer matrix (2d array) and find the sum of all 2-digit and 3-digit positive numbers separately in C programming. To know more about two dimensional array click on the two dimensional array lesson.

Q2) Write a program in C to input numbers in a 3X3 integer matrix (2d array) and find the sum of all 2-digit and 3-digit positive numbers separately.

#### Program

``````#include <stdio.h>
#include <conio.h>

int main()
{
int a[3][3], r,c,s1=0,s2=0;

printf("Enter 9 numbers\n");
for(r=0; r<3; r++)
{
for(c=0; c<3; c++)
{
scanf("%d",&a[r][c]);
if(a[r][c]>=10 && a[r][c]<=99)
{
s1=s1+a[r][c];
}
else if(a[r][c]>=100 && a[r][c]<=999)
{
s2=s2+a[r][c];
}
}
}
printf("Sum of 2 digit positive numbers = %d\n",s1);
printf("Sum of 3 digit positive numbers = %d",s2);
return 0;
}``````

#### Output

```Enter 9 numbers
12
4
69
124
36
221
96
5
7
Sum of 2 digit positive numbers = 213
Sum of 3 digit positive numbers = 345```