c++ - User is entering 10 numbers, find max negative value and its index/position -


user entering 10 numbers, find max negative value , index/position.

ps: must use "for". plz -_-"

this code:

#include <iostream>  using namespace std;  int main() {      double value, maxvalue, index;      cin >> value;     maxvalue = value;     index = 1;      (int = 2; <= 10; i++) {         cin >> value;          if (value > maxvalue&&value<0) {             maxvalue = value;                 index = i;         }      }     cout << "max value = " << maxvalue << " index = " << index << endl;   } 

change line

if (value < maxvalue && value<0) 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -