|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
i have got a quizz to write a programm that gives the sum of all even
numbers between two variables x and y and then displays the sum. Include both x and y in the total sum. Any one here can me............ ? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
* zohaib.shirani@gmail.com:
> i have got a quizz to write a programm that gives the sum of all even > numbers between two variables x and y and then displays the sum. > Include both x and y in the total sum. > > > Any one here can me............ ? You're in luck, this was recently answered by the FAQ. Since the Parashift server seems to be down, see e.g. <url: http://www.coders2020.com/cplusplus-explained/index.html>, FAQ item 5.2. Cheers, & rhth., - Alf -- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 2007-10-18 11:56, zohaib.shirani@gmail.com wrote:
> i have got a quizz to write a programm that gives the sum of all even > numbers between two variables x and y and then displays the sum. > Include both x and y in the total sum. > > > Any one here can me............ ? Start by writing a program that reads in two integers, then figure out how to get all numbers between those that you read in. Then figure out how to sum up all those numbers. Then exclude those that are odd. For more information read the FAQ, section 5.2 is particularly relevant: http://www.parashift.com/c++-faq-lit...t.html#faq-5.2 -- Erik Wikström |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 18 Oct, 10:56, zohaib.shir...@gmail.com wrote:
> i have got a quizz to [...] the idea of a "quiz" is for *you* to do the work > write a programm that gives the sum of all even > numbers between two variables x and y and then displays the sum. > Include both x and y in the total sum. > > Any one here can me............ ? in NAPSIC (Nick's All Purpose Symbolic Instruction Code) DEFINE print_sum_evens (INTEGER x, y) INTEGER sum <- 0; FOR ALL i IN RANGE (x, y) IF is_even (i) sum <- sum + i END END PRINT sum END -- Nick Keighley |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Oct 18, 4:03 pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote: > On 18 Oct, 10:56, zohaib.shir...@gmail.com wrote: > > > i have got a quizz to [...] > > the idea of a "quiz" is for *you* to do the work > > > write a programm that gives the sum of all even > > numbers between two variables x and y and then displays the sum. > > Include both x and y in the total sum. > > > Any one here can me............ ? > > in NAPSIC (Nick's All Purpose Symbolic Instruction Code) > > DEFINE print_sum_evens (INTEGER x, y) > INTEGER sum <- 0; > > FOR ALL i IN RANGE (x, y) > IF is_even (i) > sum <- sum + i > END > END > > PRINT sum > END > > -- > Nick Keighley Remember i am woking in C++ with complier VC..... Sorry 4 not telling u that |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
zohaib.shirani@gmail.com wrote:
> On Oct 18, 4:03 pm, Nick Keighley <nick_keighley_nos...@hotmail.com> > wrote: >> On 18 Oct, 10:56, zohaib.shir...@gmail.com wrote: >> >>> i have got a quizz to [...] >> the idea of a "quiz" is for *you* to do the work >> >>> write a programm that gives the sum of all even >>> numbers between two variables x and y and then displays the sum. >>> Include both x and y in the total sum. >>> Any one here can me............ ? >> in NAPSIC (Nick's All Purpose Symbolic Instruction Code) >> >> DEFINE print_sum_evens (INTEGER x, y) >> INTEGER sum <- 0; >> >> FOR ALL i IN RANGE (x, y) >> IF is_even (i) >> sum <- sum + i >> END >> END >> >> PRINT sum >> END >> >> -- >> Nick Keighley > > Remember i am woking in C++ with complier VC..... Sorry 4 not telling > u that > and how many tablespoon of sugar would you like in the coffee, sir? Regards, Zeppe |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
zohaib.shirani@gmail.com wrote:
> On Oct 18, 4:03 pm, Nick Keighley <nick_keighley_nos...@hotmail.com> > wrote: >> On 18 Oct, 10:56, zohaib.shir...@gmail.com wrote: >> >>> i have got a quizz to [...] >> the idea of a "quiz" is for *you* to do the work > > Remember i am woking in C++ with complier VC..... Sorry 4 not telling > u that I think you're far more likely to get here by showing what you have done so far rather than making a request for someone else to show you how to do it. What have you tried so far? LR |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
zohaib.shirani@gmail.com wrote in news:1192705580.055095.159270
@e9g2000prf.googlegroups.com: > On Oct 18, 4:03 pm, Nick Keighley <nick_keighley_nos...@hotmail.com> > wrote: >> On 18 Oct, 10:56, zohaib.shir...@gmail.com wrote: >> >> > i have got a quizz to [...] >> >> the idea of a "quiz" is for *you* to do the work >> >> > write a programm that gives the sum of all even >> > numbers between two variables x and y and then displays the sum. >> > Include both x and y in the total sum. >> >> > Any one here can me............ ? >> >> in NAPSIC (Nick's All Purpose Symbolic Instruction Code) >> >> DEFINE print_sum_evens (INTEGER x, y) >> INTEGER sum <- 0; >> >> FOR ALL i IN RANGE (x, y) >> IF is_even (i) >> sum <- sum + i >> END >> END >> >> PRINT sum >> END >> >> -- >> Nick Keighley > > Remember i am woking in C++ with complier VC..... Sorry 4 not telling > u that > Nick is very well aware that you wanted C++ code. Which is exactly why he didn't write his program in C++. He's not going to hand you the solution on a silver platter (neither will anybody else here). The point is for _you_ to do the work, not for one of us to do it for you. You won't learn anything that way. |
|
![]() |
| Outils de la discussion | |
|
|