943,795 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 16428
  • C++ RSS
You are currently viewing page 6 of this multi-page discussion thread; Jump to the first page
Aug 18th, 2005
0

Re: Deitel's "C++ How To Program" exercise 2.18

is it like this




#include<iostream>
using namespace std;

int main()
{
for(i = 0; i<=11; i++){
printf("enter a temperature:");
cout<<"monthly temperature:"
scanf("%f", &monthlytemperature[i]);
}
}
Reputation Points: 10
Solved Threads: 0
Light Poster
mugilan is offline Offline
33 posts
since Aug 2005
Aug 18th, 2005
0

Re: Deitel's "C++ How To Program" exercise 2.18

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){
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Aug 18th, 2005
0

Re: Deitel's "C++ How To Program" exercise 2.18

#include<iostream>
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
Reputation Points: 10
Solved Threads: 0
Light Poster
mugilan is offline Offline
33 posts
since Aug 2005
Aug 18th, 2005
0

Re: Deitel's "C++ How To Program" exercise 2.18

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Aug 18th, 2005
0

Re: Deitel's "C++ How To Program" exercise 2.18

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.
Reputation Points: 10
Solved Threads: 3
Newbie Poster
nattylife is offline Offline
14 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: fstream to char and int array
Next Thread in C++ Forum Timeline: How to create a registry?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC