Mugilan --
Just wanted to write you and encourage you NOT to give up. Look at all you have learned so far. Keep on trying, and you will get it. No one writes a program perfectly the first time (except perhaps Narue, but she is a coding Goddess).
Keep working at it. You are well on the way, and in the end, you will feel good that you did the hard parts yourself. That is the honorable thing to do! You are in good hands with Dave.
Christian
kc0arf
Posting Virtuoso
1,937 posts since Mar 2004
Reputation Points: 121
Solved Threads: 57
did you compile and run your program? If not, then you should do so to see the output. But for now, I would change "while(frue)" to something that will limit the output to the first 10 numbers or so and then quit on its own. It will make debugging a little easier.
To get powers of two requires multiplication. for example, 1*2 = 2, 2 * 2 = 4, 4 * 2 = 8, 8 * 2 = 16, ...
Or you can also do it my addition , 1 + 1 = 2, 2 + 2 = 4, 4 + 4 = 8, 8 + 8 = 16, 16 + 16 = 32, ...
with that in mind, now look at your program. the calculations inside the while loop are all wrong. all you need is one variable -- f0 -- and add it to itself
int f0 = 1;
// power of 2
f0 = f0 + f0;
cout << f0 << ", ";
Ancient Dragon
Retired & Loving It
30,040 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
thanks i am done with that question.....can you help on this.... read 12 values for double array monthly temperatures from the keyboard......write single statement that perform,,,,
And I suppose you want me to take your classes for you and do all your homework :mrgreen:
Ancient Dragon
Retired & Loving It
30,040 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
I haven't read this whole thread, so I don't know what all those ... mean in your previous post.
did you try to compile it? Obviously not because it contains a few syntax errors, like missing declarations of variables.
when you want to count from 0 to (but not including) 12, most people code it like this:
for(i = 0; i < 12; ++i){
Ancient Dragon
Retired & Loving It
30,040 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
what compiler are you using? Your program still has several syntax errors and the compiler should have spit out several error messages. Did you fix them? or just ignore them? NEVER ignore errors and warnings. Nobody can help you very much if you don't post exactly what you tried to compile -- I forgot to being my crystle ball today.
Ancient Dragon
Retired & Loving It
30,040 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341