C
C#2y ago
matuda.

❔ Smaller number in a Loop

Write a console application that determines the smallest element in a given string of integers. The numbers are entered one by one, and the application will read them one by one until the user enters the number 0. When the number 0 is entered, the application knows that all the numbers in the string have been entered and displays the smallest one. The number 0 is also part of the string and if it is the smallest number entered by the user then the application will return 0. Example: For input data: 24 1 -3 3 -1 0 The console will display: -3 I find out i have to use for but i don't know how to apply
20 Replies
Cracker
Cracker2y ago
have you tried chat gpt ?
Tvde1
Tvde12y ago
Don't Do it yourself, that's how you learn Can you break down these functionalities in smaller steps? It's easier to build smaller parts of logic than a big one I can divide the requirements in 3 steps kinda The last step being "print the found number on the screen"
matuda.
matuda.OP2y ago
I'm not a big fan of Ai in learning but this thing spoil everithing. I didn't expect to solve like that :)))) I shouldn't done that Ai gaved me wrong nevermind
Moods
Moods2y ago
is it a requirement to use a for loop?
matuda.
matuda.OP2y ago
yep
Moods
Moods2y ago
best way to approach this is to break it down into steps like it was said earlier find your input, find what you need to do to it(processing), then use that processed data according to what is required(in this case it's to display) how will you capture user input?
matuda.
matuda.OP2y ago
Wrenpo
Wrenpo2y ago
- read input - check/compare input to validation (that 0 is key here) - store the inputs somehow to compare for minimum number - print back to user
Moods
Moods2y ago
if 0 can be a valid input put the if...break after the min check and from this
The number 0 is also part of the string and if it is the smallest number entered by the user then the application will return 0.
The number 0 is also part of the string and if it is the smallest number entered by the user then the application will return 0.
it looks like it is
Wrenpo
Wrenpo2y ago
Also, once you figure out the baseline of how to get this functional... Try to think from a user's shoes. Can they input anything else besides numbers? How can I break this?
matuda.
matuda.OP2y ago
I made the changes and it worked. Thanks Can I ask you something?@Moods@Wrenpo? I know it's a weird question but how you guys did learn how to code?
Wrenpo
Wrenpo2y ago
I learned from books at first and asking friends that already knew how to code. I played with the code until I created something I wanted. Lots of trial and error. Still is.
Moods
Moods2y ago
Uh, I’m still learning tbh, it’s a continuous thing :) With C# watched a bunch of vids then made the Microsoft C# and .NET documentation my home
matuda.
matuda.OP2y ago
Did you guys work in a company or still learning?
Moods
Moods2y ago
Still learning 🫡 I only picked it up cus I was super interested in C# and its intricacies tbh, I have no idea how it’s like in a corporate setting since I’m moreso interested in being a teacher If you wanna know how it is #career-talk should help I like backreading the stuff there. Really insightful stuff
matuda.
matuda.OP2y ago
Owwww! I forgot about that chanel.
Cracker
Cracker2y ago
If you ask the questions in right way, it is supporting to learn rather than direct answer, its up to you anyways
Henkypenky
Henkypenky2y ago
no, there is a point in time when you should use chat gpt, and this is definitely not it. This exercise sounds like 101 to me, so the OP is new and you are suggesting they go to chat gpt to understand why, they will never understand why. How do you think we managed when chat gpt didn't exist? Hard work and asking for help. Chat gpt is cheating in this scenario not just cheating, it's cheating yourself, which is worse so yes, stop suggesting chat gpt for people that are absolute beginners
Omnissiah
Omnissiah2y ago
why should 0 end the sequence if it's a valid integer wouldn't be wise to use something else, like empty line?
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server