Discover the answers you need at Westonci.ca, a dynamic Q&A platform where knowledge is shared freely by a community of experts. Connect with a community of experts ready to provide precise solutions to your questions on our user-friendly Q&A platform. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.
Sagot :
Answer:
#include <stdio.h>
int main() {
int p=0, n=0, z=0, inp=0;
printf("How do I write a C program to read numbers until -1 "
"is encountered and also count the number of positive, negative, "
"zeroes encountered by users using a while loop?\n\n\n");
printf("Enter an integer (-1 to quit): ");
scanf("%d",&inp);
while(inp != -1) {
if(inp > 0) p++;
else if(inp < 0) n++;
else z++;
printf("\nEnter next integer (-1 to quit): ");
scanf("%d",&inp);
}
n++; /* -1 is also a -ve number */
printf("You have entered ...\n");
printf("\t\tPositive numbers: %d\n",p);
printf("\t\tNegative numbers: %d\n",n);
printf("\t\t Zeroes: %d\n",z);
}
Explanation:
Thank you for your visit. We are dedicated to helping you find the information you need, whenever you need it. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Keep exploring Westonci.ca for more insightful answers to your questions. We're here to help.