Last active
April 29, 2021 08:49
-
-
Save btechmag/e09baf3e5fe0cdc66b657a0dfd4e12dd to your computer and use it in GitHub Desktop.
C Program that reads 5 numbers and counts the number of positive and negative numbers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
//Program that reads 5 numbers and counts the number of positive and negative numbers | |
int n[5]; | |
int i,pos = 0,neg = 0; | |
for(i = 0; i < 5; i++) | |
{ | |
printf("Input the elements n[%d] : ", i); | |
scanf("%d", &n[i]); | |
{ | |
if(n[i] > 0) | |
{ | |
pos++; | |
} | |
else if(n[i] < 0) | |
{ | |
neg++; | |
} | |
} | |
} | |
printf("Number of positive numbers: %d\n" ,pos); | |
printf("Number of negative numbers: %d" ,neg); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment