How many times should the value of inputCount be read?

  • Context: MHB 
  • Thread starter Thread starter Chrisanchez
  • Start date Start date
  • Tags Tags
    Format Integers
Click For Summary

Discussion Overview

The discussion revolves around the interpretation of a programming problem related to reading input values in a specific manner. Participants are examining how many times the variable inputCount should be read based on the problem statement, and how this affects the output of subsequent integers.

Discussion Character

  • Debate/contested
  • Technical explanation

Main Points Raised

  • One participant suggests that inputCount should be read once to determine how many integers to output, based on the example provided.
  • Another participant expresses confusion about the program's behavior, noting that it repeats the last output value multiple times.
  • Some participants argue that the problem statement implies inputCount should be read twice, while others challenge this interpretation and request clarification from the original text.
  • There is a request for a direct quote from the problem statement to clarify how many times inputCount should be read, emphasizing the need for precise interpretation.

Areas of Agreement / Disagreement

Participants do not reach a consensus on how many times inputCount should be read. There are competing interpretations of the problem statement, leading to ongoing debate.

Contextual Notes

There is uncertainty regarding the interpretation of the problem statement, particularly about the phrasing related to reading inputCount and the expected output format. Participants are focused on clarifying these aspects without resolving the underlying disagreement.

Who May Find This Useful

This discussion may be useful for programmers or students working on input handling in coding exercises, particularly those dealing with reading and processing multiple inputs based on specified conditions.

Chrisanchez
Messages
3
Reaction score
0
First, read in an input value for variable inputCount. Then, read inputCount integers from input and output each integer on a newline after the string "value - ".
Ex: If the input is 2 25 55, the output is:
value - 25
value - 55
Code:
#include <iostream>
using namespace std;

int main() {
int inputCount;
int i;
cin >> inputCount;
for(i=0; inputCount > i | | inputCount < i; ++i){
cin >> inputCount;
count << "value - " << inputCount << endl;
}
return 0;
}
I'm having trouble figuring out what I'm doing wrong, I able to get the output that I wanted but it keeps repeating the last output that is needed. for example the output that I'm getting is "value - 25 value - 55 value -55 . . ." and it keeps repeating the last output.
 
Technology news on Phys.org
How many times should the program read inputCount according to the problem statement? How many times does your program read inputCount?
 
Evgeny.Makarov said:
How many times should the program read inputCount according to the problem statement? How many times does your program read inputCount?
It should read inputCount 2 times and output the values after the initial stated amount of times. for example the values are 3, 20, 26, -20. So it should read the 3 as how many times down the list it should output, for example the code output should be 20, 26, -20. But my code for some reason, i do not know, will read the last value, -20, and continue to repeat it for more than 10 times when I need it to read it once.
 
Chrisanchez said:
It should read inputCount 2 times
Please convince me that the problem statement really says this. Show me the exact quote and explain why you think the program should read the value of inputCount two times. I suggest using short and clear sentences.
 
Evgeny.Makarov said:
Please convince me that the problem statement really says this. Show me the exact quote and explain why you think the program should read the value of inputCount two times. I suggest using short and clear sentences.
This is the question that they are asking me:
First, read in an input value for variable inputCount. Then, read inputCount integers from input and output each integer on a newline after the string "value - ".
Ex: If the input is 2 25 55, the output is:
value - 25
value - 55
 
I have already read the problem statement in post #1. There is no need to repeat it. I asked you to provide a small quote that says that the value of inputCount should be read twice. Do you agree, for example, that the phrase 'output each integer on a newline after the string "value - "' has nothing to do with reading inputCount? Then why do you quote it? Please quote only the relevant part that says how many times inputCount should be read. Also describe how you interpret that quote, why do you think it says what is says.
 

Similar threads

  • · Replies 29 ·
Replies
29
Views
3K
Replies
12
Views
3K
Replies
6
Views
1K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 1 ·
Replies
1
Views
6K
Replies
10
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 4 ·
Replies
4
Views
14K
  • · Replies 3 ·
Replies
3
Views
2K