Count positive and negativewrite a c program to that allows the user to enter 'n' numbers and finds the number of positive numbers entered and the number of negative numbers
Answers
Answered by
1
Answer:
Explanation:
#include <stdio.h>
int main()
{
int n=6; //no of integers
int countp=0,countn=0,k; //countp counts positive ,countn counts negative no.
for(k=1;k<=n;k++)
{
int num;
printf("Enter %dth number",k);
scanf("%d",&num);
if(num>0)
countp++;
if(num<0)
countn++;
}
printf("total number of positive integers is %d and negative numbers is %d",countp,countn);
return 1;
}
Similar questions
English,
6 months ago
Math,
11 months ago
Computer Science,
11 months ago
Social Sciences,
1 year ago
Biology,
1 year ago
Chemistry,
1 year ago