Sum of 'n' positive numbers in C Programming

Sum of 'n' positive numbers
Image result for c programming
Code:
  #include<stdio.h>
int main()
{
  int n,i;
  int a, count=0,sum=0;
  printf("Enter the value of n\n");
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    printf("Enter the number\n");
    scanf("%d",&a);
    if(a>=0)
    {
      count++;
      sum=sum+a;
    }
  }
  printf("Number of positive numbers entered is %d and the sum is %d",count,sum);
  return 0;
}

No comments