GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Jan-2007, 00:48
C++novice C++novice is offline
New Member
 
Join Date: Jan 2007
Posts: 1
C++novice is on a distinguished road
Lightbulb

hi, guys. i'm a supernovice for c++. i have a Q to ask


can anyone tell me what's wrong with my code?
why did my computer report 32 errors for this simple program???!!!~~~~

thx guys

CPP / C++ / C Code:
#include <iostream>
#include <string>
using namespace std;

int a, b, c, d, e, f, g, h, i, j, k;
double amount;

	a=amount/100;
	b=amount%100/50;
	c=amount%100%50/20;
	d=amount%100%50%20/10;
	e=amount%100%50%20%10/5;
	f=amount%100%50%20%10%5/2;
	g=amount%100%50%20%10%5%2/1;
	h=amount%100%50%20%10%5%2%1*100/25;
	i=amount%100%50%20%10%5%2%1*100%25/10;
	j=amount%100%50%20%10%5%2%1*100%25%10/5;
	k=amount%100%50%20%10%5%2%1*100%25%10%5/1;


int main()
{
	cout<<"Enter the amount of money that you want: ";
	cin>>amount;
	cout<<"Hundreds: "<<a<<endl;
	cout<<"Fifties : "<<b<<endl;
	cout<<"Twenties: "<<c<<endl;
	cout<<"Tens    : "<<d<<endl;
	cout<<"Fives   : "<<e<<endl;
	cout<<"Twonies : "<<f<<endl;
	cout<<"Loonies : "<<g<<endl;
	cout<<"Quarters: "<<h<<endl;
	cout<<"Dimes   : "<<i<<endl;
	cout<<"Nickels : "<<j<<endl;
	cout<<"Pennies : "<<k<<endl;


	return 0;

}
Last edited by LuciWiz : 13-Jan-2007 at 05:55. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 13-Jan-2007, 09:22
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,720
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: hi, guys. i'm a supernovice for c++. i have a Q to ask


Quote:
Originally Posted by C++novice
why did my computer report 32 errors for this simple program???!!!~~~~

Well, how many errors did you expect?

One of my compilers gave 26 errors, and one gave 22, so I guess that yours wins.

However, your other question makes a little more sense:

Quote:
Originally Posted by C++novice
can anyone tell me what's wrong


Seriously: In general I think you should post the errors that you saw, since different compilers give different kinds of messages and, in order to help us help you, it is sometimes useful to go over them with you step by step. (So that next time you might be able to figure them out more quickly.) If there are numerous errors that are "almost the same" as others except for line numbers, just post the first few messages. Also, tell us what compiler you are using. Visual C++ version 6 has a number of bugs that cause erroneous error messages that don't appear in Visual C++ 2005, so sometimes it makes a difference to people who are trying to help.



In this case, I am guessing that you might have seen things like this:

Code:
test.cpp(8) : error C2501: 'a' : missing storage-class or type specifiers test.cpp(8) : error C2086: 'a' : redefinition

This is for line number eight in my copy of your code, and similar messages appeared for the next nine or ten lines.

The messages themselves probably don't mean much to you, so I'm not surprised that you need a little help. (Sometimes the error messages are pretty clear, and sometimes not --- as in this case.)

Here's the thing: In C and in C++, assignment statements must be inside a function. Your program has one function: the main(). So put the assignment statements inside main()

I suggest that you put all of your declarations inside [kbd]main()[/also].

Then you can get to the next step in debugging your program. If you still get messages that you don't understand then post them.

Regards,

Dave
  #3  
Old 23-Jan-2007, 09:45
dhawan dhawan is offline
New Member
 
Join Date: Jan 2007
Posts: 25
dhawan is on a distinguished road

Re: hi, guys. i'm a supernovice for c++. i have a Q to ask


Hi,

Every excutable code must be in any one of the functions .

regards
dhawan
 
 

Recent GIDBlogPython ebook by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
+ Hey Guys EthicsD New Member Introductions 0 10-Oct-2006 10:39
Newbie Problems. Help me guys the_last_rites Apache Web Server Forum 4 18-Jan-2005 11:57
Hi guys pls help me coolraghav Web Hosting Forum 9 21-May-2004 06:23

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:05.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.