What Does 'N' Represent in this Programming Question?

  • Thread starter Thread starter Iron_Brute
  • Start date Start date
  • Tags Tags
    Confusion Program
AI Thread Summary
In the programming question, 'N' represents the total number of values the user will input, excluding the first number which indicates how many numbers will follow. The task is to write a program that finds the smallest, largest, and average values from this collection of N numbers. The initial confusion stemmed from interpreting N as either the total count or the individual numbers themselves. Clarification was provided that the first input serves solely to define the size of the subsequent list. Understanding this concept allowed the user to successfully complete their program.
Iron_Brute
Messages
19
Reaction score
0
I'm having a problem understanding what it is N stands for. The question is

"Write a program that will find the smallest, largest, and average values in a collection of N numbers. Get the value of N before scanning each value in the collection of N numbers."

To me it looks like N can stand for 2 different values, it could be the total number of values the user would input but it could also represent the individual numbers that the user inputs.

Im writing this in C#, and finding the smallest, largest, and average values I am fairly confident I can do that it is just what the N is supposed represent that is throwing me off.
 
Technology news on Phys.org
To me, it just looks like N is referring to the whole collection of numbers in general. I don't think your prof is looking for you to specify an actual value of N, just an idea of what to do with your program.

Welcome to cryptic programming directions 101...it has only just begun
 
"Write a program that will find the smallest, largest, and average values in a collection of N numbers"

Suppose it said:"Write a program that will find the smallest, largest, and average values in a collection of 5 numbers" or "Write a program that will find the smallest, largest, and average values in a collection of 20 numbers". Would you have a problem with that?

I disagree with carrotcake10, I don't think this is ambiguous at all. This is simply telling you the first number input will NOT be a part of the list but will tell you how many numbers are in the list. For example, you should write a program that will accept in put like
7
6
4
-3
2
12
-8
7
and output the largest and smallest numbers in that list of 7 numbers as well as their average.

or accept input like
200
11
32
-24
.
.
.
for a total of 200 numbers (NOT including the first "200") and output the smallest and largest numbers in that list as well as their average.

I would recommend something like

int N;
readln N;
for (int i= 0;i< N; i++)
{

}
 
Thanks for the help, now I understand what the N variable is supposed to be for now and I finished my programm this morning. Couldn't have done it without oy.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Back
Top