Dremendo Tag Line

Input 10 numbers and find the sum of 2 digit positive numbers using for loop in C

for Loop - Question 6

In this question, we will see how to input 10 numbers and find the sum of 2 digit, positive numbers only in C programming using for loop. To know more about for loop click on the for loop lesson.

Q6) Write a program in C to input 10 numbers and find the sum of 2 digit, positive numbers only using for loop.

Program

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

int main()
{
    int i,n,s=0;

    printf("Enter 10 numbers\n");
    for(i=1; i<=10; i=i+1)
    {
        scanf("%d",&n);
        if(n>=10 && n<=99)
        {
            s=s+n;
        }
    }
    printf("Sum of 2 digit positive numbers = %d",s);
    return 0;
}

Output

Enter 10 numbers
2
4
18
20
1
9
3
5
32
46
Sum of 2 digit positive numbers = 116
video-poster