how do i do summation of n+sin(n) without A while loop, only for?

Recommended Answers

All 2 Replies

Why not post the code of how you'd do it with a while loop? Then maybe your best attempt at converting it to a for loop?

All of the parts of a for loop are optional. For example, to write an infinite loop you might do this:

for ( ; ; ) {
  /* Stuff */
}

Converting a while loop to a for loop is trivial with that little tidbit. Of course, there are other ways, but they require restructuring the loop a bit.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.