Two Digits Numbers
Accept an array of N values and print the sum S of all the two digit numbers present in the array. If there are no two digit numbers, print 0.
Input Format:
First line contains the size N
Second line contains N values seperated by a space
First line contains the size N
Second line contains N values seperated by a space
Output Format:
The first line contains S.
The first line contains S.
Boundary Condition:
1 < N < 1000
1 < N < 1000
Example Input/Output 1:
Input:
5
23 898 6 54 21
Input:
5
23 898 6 54 21
Ouput:
98
98
Example Input/Output 2:
Input:
6
231 898 6 541 2 900
Input:
6
231 898 6 541 2 900
Ouput:
0
0
c program:
#include<stdio.h>
#include <stdlib.h>
int main()
{
int a,n,i,s=0,c=0,t;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a);
c=0;
t=a;
while(t!=0)
{
t=t/10;
c++;
}
if(c==2)
s+=a;
}
printf("%d",s);
}
No comments:
Post a Comment