954,119 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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
Team Colleague
1,937 posts since Mar 2004
Reputation Points: 121
Solved Threads: 57
 

thanks

mugilan
Light Poster
33 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

can anybody help me on this question write a program that use a statement to calculate and print the average of several integers. assume the last value read is the sentinel 9999. a typical input sequence might be

10 8 11 7 9 9999

mugilan
Light Poster
33 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

10,,,,,8,,,,,11,,,,,7,,,,,9,,,,,,,9999

mugilan
Light Poster
33 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

can you help me please on this question..................


write single statements that performs the following on,

intialize the 10 elements of integer array counts to zero
add 1 to each of the 15 elements of integer array bonus
read 12 values for double array monthly temperatures from the keyboard
print the 5 values o integer array best score in column format

mugilan
Light Poster
33 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

write a program that prints the powers of the nteger 2, namely 2,4,8,16,32,64, etc your while loop should not terminate(i.e you should create an infinite loop) to do this, simply use keyword true as the expression for while statement. what happens when you run this program.....

#include
using std::cout;
using std::cin;
using std::endl;

int main()
{
long bound;
cout<<"enter a positive integer:";
cin>>bound;
cout<<"fibonacci numbers <"<+c.)
{
long f2 = f0 + f1;
cout <<","<< f2;
f0 = f1;
f1 = f2;
}
return 0;
}

i write this program for that question......are this is correct or i need to change it

mugilan
Light Poster
33 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

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
Team Colleague
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,,,,

mugilan
Light Poster
33 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 
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
Team Colleague
30,040 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 

no.....please help me only ones

mugilan
Light Poster
33 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

is it like this


#include
using namespace std;

int main()
{
for(i = 0; i<=11; i++){
printf("enter a temperature:");
cout<<"monthly temperature:"
scanf("%f", &monthlytemperature[i]);
}
}

mugilan
Light Poster
33 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

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
Team Colleague
30,040 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 

#include
using namespace std;
int i;
typedef float sequence[];

int main()

{

for (i = 0; i<=12; i++){
printf("enter a Temperature:");
scanf("%f", "&monthly Temperature[i]");
}
}


when it runs...it say run time error

mugilan
Light Poster
33 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

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
Team Colleague
30,040 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 

use your book and compare the syntax of what you wrote to examples in the book. if they look good, then do a dry run of your program on paper, write out each variable and what happens to its contents in each iteration of the loop. maybe youll find an error in your logic...(although in the last case its a syntax prob)
understand the concepts first, then attempt the code, unless it seems intuitive, dont just read the chapter and tackle the questions. understanding is a must.

nattylife
Newbie Poster
14 posts since Aug 2005
Reputation Points: 10
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You