| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| Engineer Expert Cheater
 
  Reputation: 1 
 Joined: 25 Nov 2007
 Posts: 170
 
 
 | 
			
				|  Posted: Wed Nov 28, 2007 5:34 am    Post subject: erm, need source code help [c++ begginer stuff] |   |  
				| 
 |  
				| im trying to make a multiplying calculator trought a simple cmd code, but when i tryed compiling it.... 15 errors   
 heres the source code
 
 typedef unsigned short USHORT
 #include <iostream.h>
 using namespace std ;
 USHORT FindProduct(USHORT OneToWrigth, USHORT Multy);
 
 int main()
 {
 USHORT Product;
 USHORT Multy;
 USHORT OneToWrigt;
 
 cout << "Insert number to multiply: ";
 cin >> OneToWrigt;
 cout << "Number multiplyed by? ";
 cin >> Multy;
 
 Product = FindProduct(OneToWrigt,Multy);
 
 cout << "\nThe number is: ;
 cout << Product;
 return 0;
 }
 
 USHORT FindProduct(USHORT w, USHORT m);
 {
 return w * m;
 }
 
 
       
 can someone tell me waths wrong in the script?
 
 Last edited by Engineer on Wed Nov 28, 2007 6:23 am; edited 1 time in total
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Aikos Cheater
 
  Reputation: 0 
 Joined: 26 Nov 2007
 Posts: 47
 
 
 | 
			
				|  Posted: Wed Nov 28, 2007 5:50 am    Post subject: |   |  
				| 
 |  
				| 1. missing semicolons in a number of places 2. I guess you need "using namespace std;" before your code in order to use cin/cout without adding std:: before the functions.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Engineer Expert Cheater
 
  Reputation: 1 
 Joined: 25 Nov 2007
 Posts: 170
 
 
 | 
			
				|  Posted: Wed Nov 28, 2007 6:02 am    Post subject: |   |  
				| 
 |  
				| dangit those semicolons   editing it later, gotta eat now, thanks ill say if i get more errors
 
 EDIT i added semicolons and namespace std and i even got more errors!!!!
 (editing the 1st post for the actual code)
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| appalsap Moderator
 
  Reputation: 0 
 Joined: 27 Apr 2006
 Posts: 6753
 Location: Pakistan
 
 | 
			
				|  Posted: Wed Nov 28, 2007 6:48 am    Post subject: |   |  
				| 
 |  
				|  	  | Code: |  	  | #include <iostream>
 
 unsigned short FindProduct(unsigned short OneW, unsigned short Multy)
 {
 return (OneW * Multy);
 }
 
 int main(int argc, char* argv[])
 {
 unsigned short product, Multy, OneW;
 
 std::cout << "Insert number to multiply: ";
 std::cin >> OneW;
 std::cout << "Multiplied by? ";
 std::cin >> Multy;
 
 product = FindProduct(OneW, Multy);
 
 std::cout << std::endl << "The product is:" << std::ends << product;
 
 return 0;
 }
 
 | 
 _________________
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Engineer Expert Cheater
 
  Reputation: 1 
 Joined: 25 Nov 2007
 Posts: 170
 
 
 | 
			
				|  Posted: Wed Nov 28, 2007 7:21 am    Post subject: |   |  
				| 
 |  
				| thanks, it dosnt has any error, but it after Multy is defined it shuts down   |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| appalsap Moderator
 
  Reputation: 0 
 Joined: 27 Apr 2006
 Posts: 6753
 Location: Pakistan
 
 | 
			
				|  Posted: Wed Nov 28, 2007 7:22 am    Post subject: |   |  
				| 
 |  
				| add 
 
  	  | Code: |  	  | std::cin.get();
 std::cin.sync();
 
 | 
 
 before
 
 
 _________________
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Engineer Expert Cheater
 
  Reputation: 1 
 Joined: 25 Nov 2007
 Posts: 170
 
 
 | 
			
				|  Posted: Wed Nov 28, 2007 7:27 am    Post subject: |   |  
				| 
 |  
				| still closes   |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| appalsap Moderator
 
  Reputation: 0 
 Joined: 27 Apr 2006
 Posts: 6753
 Location: Pakistan
 
 | 
			
				|  Posted: Wed Nov 28, 2007 7:33 am    Post subject: |   |  
				| 
 |  
				| run the program from the command line 
 or use an IDE that automatically pauses the console for you, like MSVC or Code::Blocks
 _________________
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  |