Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
help me with c++

 
Post new topic   Reply to topic Printable version
 View previous topic  i got banned and wana start all over a... Post :: Post i got ddos'ed  View next topic  
Author Message
kinghellz
Guest


Offline

PostPosted: Sat Oct 06, 2007 8:39 pm   Post maybe stupid    Post subject: help me with c++ Reply to topic Reply with quote

im just learning c++, and working on my small project minicalculator, for some reason when i add any two numbers i get answer like 121545123157 instead of a real answer which is 10 or 20. If you can find any errors in my code il be apreciated

Code: Show/Hide
/*my first program after not pragraming for a year
ShellExecute(NULL, "open", "http://a3studio.4t.com", NULL, NULL, SW_SHOWNORMAL); this command brings u to this website
*/

#include <iostream>
#include <stdlib.h>
#include <windows.h>
using namespace std;

#define PI 3.14 //defines pi so pie now = to 3.14

int main()
{
    SetConsoleTitle("Mini Calculator");  // title
    SetCursorPos(0,0);                    //cursor position
   
    HANDLE text;                              //handle variable
    text = GetStdHandle(STD_OUTPUT_HANDLE);     //make it that
    SetConsoleTextAttribute(text,FOREGROUND_GREEN); //text attribute
   
    menu:
   
    int choice;
    cout<<"Welcome to MiniCalculator \n\n";
    cout<<"Type in 1 and press enter to add"<<endl;
    cout<<"Type in 2 and press enter to subtract"<<endl;
    cout<<"Type in 3 and press enter to multiply"<<endl;
    cout<<"Type in 4 and press enter to divide"<<endl;
    cout<<"Type in 5 and press enter to find area/perimiter of a circle"<<endl;
    cout<<"Type in 6 and press enter to go to google.com"<<endl;
    cout<<"Type in 7 and press enter to exit"<<endl;
    cout<<"Type in your choice and press enter: ";
    cin>>choice;
   
    switch (choice){
           case 1:
                int a;
                int b;
                int c;
               
                c = a + b;
               
                cout<<"\n\n Type in and press enter the number you want to add to: ";
                cin>>a;
                cout<<"\n\n Now type in and press enter the number you want to add: ";
                cin>>b;
                cout<<"The Result is "<<c<<".\n\n\n\n";
                system("pause");
                cout<<"n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
                goto menu;
                }
               
               
                return 0;
                }
               
               
   
    [quote][/quote]
Back to top
kinghellz
Guest


Offline

PostPosted: Sat Oct 06, 2007 8:46 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

oh yea its not finished so dont say i missed out the rest 2-7 choices
Back to top
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sat Oct 06, 2007 10:24 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

c++ programs are executed in order, one line at a time. So when you do "c = a + b" it takes whatever is in a and b at that point in the program and stores in in c.

so doing something like

Code: Show/Hide
c = 5;
c=10;
cout << c;


is perfectly legal and would print out 10. The program first puts 5 into c, then 10, then prints out c, which is 10.
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
baseball43v3r
Seasoned Helper


Joined: Jan 02 2006
Posts: 102
Offline

PostPosted: Sun Oct 07, 2007 12:56 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

basically what he is saying is that you have to move this line:

c = a + b;

after you input a and b. and then you output c.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sun Oct 07, 2007 1:51 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

NEVERMIND I GOT CONFUSED
Back to top
View users profile Send private message Add User to Ignore List AIM Address
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Sun Oct 07, 2007 1:41 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Quote:
cout<<"n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";


lol
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Trash Talk All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 24 page(s) served in previous 5 minutes.

phpBB Created this page in 0.557309 seconds : 30 queries executed (89.0%): GZIP compression disabled