Two Digits Numbers Sum

 

                          Two Digits Numbers Sum

 

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
Output Format:
The first line contains S.
Boundary Condition:
1 < N < 1000
Example Input/Output 1:
Input:
5
23 898 6 54 21
Ouput:
98
Example Input/Output 2:
Input:
6
231 898 6 541 2 900
Ouput:
0

Code:

#include <iostream>
int main(){
 int n,i,sum=0;
 std::cin>>n;
 int arr;
 for(i=0;i<n;i++)
 {
     std::cin>>arr;
     if(arr>=10&&arr<=99)
        sum+=arr;
 }
 std::cout<<sum;
}

Please do comment If u have any Queries!

Add a Comment

Your email address will not be published. Required fields are marked *