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

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2005
Posts: 31
Reputation: mugilan is an unknown quantity at this point 
Solved Threads: 0
mugilan mugilan is offline Offline
Light Poster

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

 
0
  #51
Aug 18th, 2005
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]);
}
}
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,626
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1496
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

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

 
0
  #52
Aug 18th, 2005
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){
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 31
Reputation: mugilan is an unknown quantity at this point 
Solved Threads: 0
mugilan mugilan is offline Offline
Light Poster

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

 
0
  #53
Aug 18th, 2005
#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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,626
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1496
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

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

 
0
  #54
Aug 18th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 14
Reputation: nattylife is an unknown quantity at this point 
Solved Threads: 3
nattylife nattylife is offline Offline
Newbie Poster

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

 
0
  #55
Aug 18th, 2005
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC