How to Create a program in C that accepts a set of integers and finds the number of positive and negative numbers.And the program stops when the user enters 0 for the integer value.
1
Expert's answer
2012-07-05T07:29:00-0400
#include "stdafx.h" #include <iostream>
using namespace std; int main() { int arrayofnumbers[100]; int number=0; cin>>number; int count=0; while(number!=0){ arrayofnumbers[count]=number; count++; cin>>number; } cout<<"Positive numbers: "; for(int i=0;i<count;i++){ if(arrayofnumbers[i]>0){ cout<<arrayofnumbers[i]<<" "; } } cout<<" Negative numbers: "; for(int i=0;i<count;i++){ if(arrayofnumbers[i]<0){ cout<<arrayofnumbers[i]<<" "; } } cin>>number; return 0; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment