Tenth Digit Odd Average



C CODE:

#include<stdio.h>
#include <stdlib.h>

int main()
{
int i,j,n,k=0,t=0,p=1;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
{
    scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
    if((((a[i]/10)%10)%2)!=0)
    {
        t=t+a[i];
        k++;
        p=0;
    }
}
float t3;
t3=(float)t/k;
if(p==0)
printf("%.2f",t3);
else
printf("0.00");
}

Comments

Popular posts from this blog

Reverse String Till Underscore

Count of common characters in two strings

RECTANGULAR SUM