❔ 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
have you tried chat gpt ?
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"
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
is it a requirement to use a for loop?
yep
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?
- 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
if 0 can be a valid input put the if...break after the min check
and from this it looks like it is
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?
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?
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.
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
Did you guys work in a company or still learning?
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
Owwww! I forgot about that chanel.
If you ask the questions in right way, it is supporting to learn rather than direct answer, its up to you anyways
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
why should 0 end the sequence if it's a valid integer
wouldn't be wise to use something else, like empty line?
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.