C Program To Count Number Of Positive And Negative Number | C Programming

C Program To Count Number Of Positive And Negative Numbers

#include<stdio.h>        
int main()
{        
  int a[50],n,count_neg=0,count_pos=0,i;          
  printf("Enter the size of the array\n");        
  scanf("%d",&n);        
  printf("Enter the elements of the array\n");      
  for (i=0;i < n;i++)          
    scanf("%d",&a[i]);        
  for(i=0;i < n;i++)      
  {                
    if(a[i] < 0)                        
      count_neg++;              
    else                      
      count_pos++;          
  }        
  printf("There are %d negative numbers in an array\n",count_neg);          
  printf("There are %d positive numbers in an array\n",count_pos);
  return 0;
}  


 Output For Above Program

C Program To Count Number Of Positive And Negative Number

Comments

Popular posts from this blog

C Program for SCAN Disk Scheduling Algorithm | C Programming

C program to Find Cartesian Product of Two Sets | C programming

C Program To Check The String Is Valid Identifier Or Not | C Programming