#Sum of natural numbers

1 messages ยท Page 1 of 1 (latest)

uneven lagoonBOT
#

When your question is answered use !solved or the button below to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

split crag
#

What does it do to output?

hollow stream
#

for the 4th time, will you tell me what we are looking at?

#

hello, hello, what's that on the screenshot, hello?

glad bay
#

I think it would be worthwhile for you to learn how to use a debugger

#

You can step through your code, line by line, and see how your variables change

hollow stream
#

it must be a case of a help vampire

glossy tinsel
split crag
#

What total is doing here?

split crag
hollow stream
#

I've asked you, multiple times already, what is on your screenshot

split crag
#

I need help with code thats why

hollow stream
#

I'm asking what is the screenshot from

#

what's the site/tool

#

what we are looking at

split crag
#

programiz

hollow stream
split crag
#

yes

hollow stream
#

thank you

split crag
#

Np

#

Can someone explain this code step by step?

hollow stream
#

I second what Raccoon said - time to learn to use a debugger

#

it will let you see how the program runs line by line, where it goes and what it does

flat pendant
#

Basically is declares n , then set n to the thing you input with scanf , then loops over n time and every time , it adds i to the total and then increment i by 1 , and then return the total

hollow stream
#

including the state of variables at each step

split crag
#

Vital tell me in simpler terms

#

Please

#

Ok so it creates n variable i get it,then scanf(user input of n)

flat pendant
#

In th case it loops over 2 times :

Loop 1 :
(i = 1)
(Total = 0)
total = total + i (so 0 + 1)
i = i + 1 ( so 1+1 )

Loop 2 :
(i = 2)
(total = 1)
total = total + i (so 1 + 2)
i = i + 1 (so 2 + 1)

#

And then it continues looping depending on how many loops you entered into the program

#

n is the thing to limit how many time you loop and every time you loop it does the thing inside of the while statement

split crag
#

Ok for example i enter 4

#

What it does?

flat pendant
#

Same thing as here;

split crag
#

oh ok

#

what while does here?

flat pendant
#

while(something) checks that the condition something is true

scenic mirage
#

!vampire

uneven lagoonBOT
# scenic mirage !vampire
Help Vampires :vampire:

"Help Vampires" are people who will continually ask for help on a problem in the hope that someone will do their work for them while putting little to no effort in themselves.
We try to be helpful and a friendly community, however, please be mindful that folks on this discord are volunteering their time to help others learn. It's a waste of their time to be asked to teach you stuff you easily could have figured out yourself.

Symptoms of a Help Vampire :bat:
  • Inability to use google effectively
  • Inability to read any documentation
  • Inability to "try it and see"
  • Inability to provide a minimal example of the problem and instead posting walls of text, screenshots, and pastebin links.
  • Inability to provide relevant information, expecting helpers to have the same context they do
  • Expects answers to be handed to them
  • No apparent increase in comprehension after questions are answered
  • Targets a previous answerer hours or days later, often on unrelated matters
Examples :garlic:
  • "Does this work?"
  • "Can someone link me to XYZ?"
  • "How the SKIBIDI do I implement a segmentation tree"
flat pendant
# split crag Can you explain simpler?

The thing in the parentheses is a thing that will be checked every time it loops , for an exemple i >= n means that if i somehow becomes greater or equals to n , then the loop will stop

#

Also you can mark this as solved

#

And i won't explain more atp

split crag
#

Itโ€™s i<=n

#

Not bigger

split crag
#

I will always be bigger than n

#

In this code

flat pendant
#

No it will not since n is the value you enter and i is set to 1

split crag
#

Ok first loop

#

i is 2

#

For example I type n (2)

#

i is 3

#

I type 3

#

i is 4

flat pendant
#

You type once every time the program is launched , not every loop

#

Because when you type you are not in the while loop

split crag
#

I know that if I type 4 the result will be 10

#

I know that now

#

I mean total

flat pendant
#

This has to be ragebait

#

You have a box that starts with 0 candies. You count from 1 up to the number you chose. Each time you count a number, you put that many candies into the box. When you finish counting, you open the box and see how many candies are inside. For 4, you put 1, then 2, then 3, then 4 candies, and the box ends up with 10 candies.

#

Not wasting any more of my time

split crag
#

Oh

#

Thank you

#

Now I understand

uneven lagoonBOT
# uneven lagoon

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

uneven lagoonBOT
# uneven lagoon

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

quick harness
#

I remember seeing this post twice in my last semester, its been a while.

scenic mirage
queen gorge
uneven lagoonBOT
#

<@undefined>

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

late void
# scenic mirage !vampire

worst part is they do the same "what does this do" across at least 3 servers, and the exact same questions and code sample for over a year now !

hollow stream
#

so an advanced case of troll?

#

a stupid-kind-of-school science experiment?

late void
#

I don't know ... it's either that or... sad

hollow stream
#

like those people doing experiment on introducing bugs to kernel, which ended up banning whole uni from kernel patches

#

because they thought it is a cool study topic

#

so maybe here we have a psycho... errr, I'm sorry, an aspiring psychologist testing something? :X :X

#

yeah, I know, I'm too optimistic

#

I didn't know they are asking the same questions, I've only remembered them asking non-stop super trivial questions

#

and requiring surprisingly hard work from others in explaining them

#

okay, that's some weird shit

late void
#

well maybe here it's unique questions, I haven't checked ๐Ÿ™‚ and also they usually don't reply once say, someone is asking what they tried to figure out on their own etc (or even once answered)

#

anyhoo...

hollow stream
#

nah, the question was exactly the same as the 3 links from history

#

and they did get their answer or multiple occasions I think

late void
#

"bad robot" ๐Ÿ™‚ ?