forked from PrabhudeepSingh/C-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountNumType.c
More file actions
37 lines (30 loc) · 773 Bytes
/
CountNumType.c
File metadata and controls
37 lines (30 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//Program to illustrate the concept of input and output of a one-dimensional array
//by calculating how many positive values, negative values or zeros are in the array
#include<stdio.h>
int main()
{
int a[20],i,n,pos=0,neg=0,zero=0;
printf("Enter number of elements : ");
scanf("%d",&n);
while(n<=0||n>20)
{
printf("\nError... Range of elements is 0 - 20 ");
printf("\nEnter the number of elements again : ");
scanf("%d",&n);
}
printf("\n");
for(i=0;i<n;i++)
{
printf("Enter the %d element : ",i+1);
scanf("%d",&a[i]);
if(a[i]>0)
pos++;
else
if(a[i]<0)
neg++;
else
zero++;
}
printf("\nPositive numbers are : %d\nNegative numbers are : %d\nZero's are : %d",pos,neg,zero);
return 0;
}