Thread: Ahh (MESSAGE BELOW IS NOT A POLL)

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    55

    Ahh (MESSAGE BELOW IS NOT A POLL)

    Hey guys. I was wonderin if you could help me out a bit. Im working on a project (Im a noob to this....) and im havin trouble with the integrars. Its a thing where they enter a number and then another number and then the program multiplys those two numbers. Well, im having trouble with the actual awnser that the program comes out with. Its like 4535363 , lol. and its stuff like 3X3..=/ i know about different integ's but none of them seem to work. Any help?
    D4050
    Glorified C++ Programmer
    Console, DOS, HTML, Javascript, Visual Basics Compatible

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    The multiply operator for C is * not X

  3. #3
    aurė entuluva! mithrandir's Avatar
    Join Date
    Aug 2001
    Posts
    1,209
    Some code perhaps would be nice.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    55
    Yea i know its Y*Z (Y and Z are user entries) ....the code is:


    #include <iostream.h>
    #include <windows.h>
    #include <stdlib.h>
    int main() {
    typedef unsigned short USHORT;
    typedef unsigned long ULONG;
    int x; //what type of int?
    int y; // what type of int?
    int z = x * y; // what type of int?
    int wait;
    int userEntry = 4050;
    cout<<"////////////// DAVES FIRST PROGRAM ///////////////"<<endl;
    cout<<" [email protected] "<<endl<<endl;
    cout<<"Hey! You want to see this program do your own simple math quotation?"<<endl;
    system("PAUSE");
    cout<<"Enter a number and press Enter.."<<endl;
    cin>>x;
    cout<<"The number you just entered was, " <<x <<endl;
    cout<<"Please Enter another number and press Enter..."<<endl;
    cin>>y;
    cout<<"Your two numbers multyplied are: " <<z <<endl;
    cout<<"Amazing eh?"<<endl;
    cout<<"Press any key(s) and Enter to Exit..";
    cin>>wait;
    return 0;
    }
    D4050
    Glorified C++ Programmer
    Console, DOS, HTML, Javascript, Visual Basics Compatible

  5. #5
    aurė entuluva! mithrandir's Avatar
    Join Date
    Aug 2001
    Posts
    1,209
    Okay now we're getting somewhere. First off though, you should have realised by now that this is C++ code, not C. However I'll help this time, but next time if you are using cout << (not printf) post on the C++ board.

    Now to the code. There was a lot of unecessary code! Read over what I've done and you should see what you didn't need. For example: <windows.h> served no practical purpose in this simple program.

    Code:
    #include <iostream.h> 
    
    int main() 
    { 
    
    	int x; //what type of int? 
    	int y; // what type of int? 
    
    
    	cout <<"////////////// DAVES FIRST PROGRAM ///////////////"<< endl; 
    	cout <<" [email protected]\n\n"; 
    	cout <<"Hey! You want to see this program do your own simple math quotation?"<< endl;
    	cout <<"Enter a number and press Enter.."<< endl; 
    
    	cin >> x; //read in the first integer
    
    	cout <<"The number you just entered was, " << x << endl; 
    
    	cout <<"Please Enter another number and press Enter..."<< endl;
    	
    	cin >> y; //read in the second integer
    
    	int z = x * y; //multiply the integers given
    
    	cout<<"Your two numbers multyplied are: " << z <<endl; 
    	cout<<"Amazing eh?"<<endl; 
    
    return 0; 
    }

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    55
    C++? Hehehe...I knew that

    Wow! It works...I had the windows.h in there for no reason wutsoever....and the stdlib.h for system("PAUSE") so it wouldnt close on me and it would show the user the awnser....thanks so much dude....im gettin somewhere now *adds you to buddy list*
    D4050
    Glorified C++ Programmer
    Console, DOS, HTML, Javascript, Visual Basics Compatible

  7. #7
    aurė entuluva! mithrandir's Avatar
    Join Date
    Aug 2001
    Posts
    1,209
    No worries. Just try to keep C++ code/topics on that board.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange string behavior
    By jcafaro10 in forum C Programming
    Replies: 2
    Last Post: 04-07-2009, 07:38 PM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. Making a script language?
    By Blackroot in forum Game Programming
    Replies: 10
    Last Post: 02-16-2006, 02:22 AM
  4. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM