C++/dev c++


Good Day!
I just can't figure out on how I can create a program that will input 20 integers. Output the number of negative values and the sum of positive numbers. I'm just a beginner, and I think this will work with looping, right?


You are right that you would need loops. Well, I have written the code for you. Try to study it. I have used STLs. something not good for beginners but if you feel that is too advanced for you, kindly let me know and I will rewrite the programme using just traditional arrays.

Good luck with your programming.

#include <iostream>
#include <vector.h>

using namespace std;
int main (int argc, char * const argv[])
  vector<int>::const_iterator index;
  int i, choice, sum  = 0;
  for (i = -5; i<20; i++)
  cout << "1.sum up all the positive numbers?"<<endl;
  cout<<"2.Find the number of negative numbers?"<<endl;
  switch (choice) {
     case 1:
         for(index=container.begin(); index!=container.end(); index++)
         sum += *index;
     case 2:
        for(index=container.begin(); index!=container.end(); index++)
       return 0;

Hello, i do not have devc++ as my IDE but I use mac xcode. That
Shouldn't be a problem. Try to clean and build the programme again.
It works perfectly fine for me. What error are you getting? What happens
When you run the programme?  


All Answers

Answers by Expert:

Ask Experts




I can confidently answer any question both basic and advanced in C++. Areas like templates, algorithms, Gui and design patterns are of interest to me. i will not answer questions about web programming.


I have a 3- year- work experience in software Engineering.

I am a bachelor of Engineering graduate

©2016 About.com. All rights reserved.