196. C Program to read Positive numbers continuously until Negative number.
How does this program work?
- In this C programme you will learn about how to read positive numbers continuously until negative number in given array of numbers.
Here is the code
#include <stdio.h>
int main(void)
{
int n,i,a[5];
printf( "Enter the size of array\n");
scanf("%d",&n);
printf("Enter elements\n");
for(i=0; i < n; i++)
{
scanf("%d",&a[i]);
}
for(i=0; i < n; i++)
{
if(a[i]<=0)
break;
printf("%d\t",a[i]);
}
return 0;
}