write a program that input 5 values from the user and display the number of positives, the number of negatives, and the number of zeros amongst the 5 values using if else if and goto.
Answers
Answer:
create the program using array.
int largestNumber;
int smallestNumber;
int numbers[n];
largestNumber=numbers[0]; smallestNumber=numbers[0];
for (i=0 ;
i<n;
i++) { if (numbers[i] > largestNumber)
{ largest = numbers[i]; } if (numbers[i] < smallestNumber) { smallestNumber= numbers[i]; } }
< marquee behaviour-move > < font color="maganta red" > < h2 > hope this helps you < / ht > < /marquee ><marqueebehaviour−move><fontcolor="magantared"><h2>hopethishelpsyou</ht></marquee>
Explanation:
#include <stdio.h>
int main() {
float numbers[5];
int j, pctr=0, nctr=0;
printf("\nInput the first number: ");
scanf("%f", &numbers[0]);
printf("\nInput the second number: ");
scanf("%f", &numbers[1]);
printf("\nInput the third number: ");
scanf("%f", &numbers[2]);
printf("\nInput the fourth number: ");
scanf("%f", &numbers[3]);
printf("\nInput the fifth number: ");
scanf("%f", &numbers[4]);
for(j = 0; j < 5; j++) {
if(numbers[j] > 0)
{
pctr++;
}
else if(numbers[j] < 0)
{
nctr++;
}
}
printf("\nNumber of positive numbers: %d", pctr);
printf("\nNumber of negative numbers: %d", nctr);
printf("\n");
return 0;
}