1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

scientific calculator

Discussion in 'Assembly Language Programming (ALP) Forum' started by RedAngel, May 3, 2010.

  1. RedAngel

    RedAngel New Member

    Joined:
    May 3, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi.........
    i want a program of scientific calcultor in assembly languge........if anyone havr plx share i really need it
    Regards
    RedAngel
     
  2. ruin

    ruin New Member

    Joined:
    Sep 1, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    medellin, cebu
    Code:
    //try this code....^_~
    #include
    
    void ssc();
    void sci();
    
    void main()
    {
    //declaration
    int num1,num2;
    char ope[4];
    
    //clearing the screen
    clrscr();
    
    //printing welcome message
    printf("\t\t\t\t***CALCULATOR***\n\tFor help: type help\n");
    
    start:
    
    cin>>ope;
    if(strcmp(ope,"end")==0) goto end;
    else if(strcmp(ope,"help")==0)
    {
    printf("\n\nTo do calculations you must first know the keyword for the specific calculation\nfor,\n\taddition - add\n\tsubtraction - sub\n\tdivision - div\n\tmultiplication - mul\n\treminder - rem\n\tclose calculator - end\n\tTo switch to scientific calculator mode - sci\tIn scientific calculator mode you can get sin,cos,tan and log values.\n\tsuccessive calculating mode - ssc\n\tYou must specify the keyword and the two numbers separated by space\n");
    goto start;
    }
    else if(strcmp(ope,"sci")==0)
    {
    sci();
    goto start;
    }
    else if(strcmp(ope,"ssc")==0)
    {
    ssc();
    goto start;
    }
    else if(strcmp(ope,"clr")==0)
    {
    clrscr();
    cout<<"\t\t\t\t***CALCULATOR***\n";
    goto start;
    }
    
    cin>>num1>>num2;
    if(strcmp(ope,"add")==0) printf("The sum of %d and %d is %d\n",num1,num2,num1+num2);
    else if(strcmp(ope,"sub")==0) printf("The difference between %d and %d is %d\n",num1,num2,num1-num2);
    else if(strcmp(ope,"mul")==0) printf("The product of %d and %d is %d\n",num1,num2,num1*num2);
    else if(strcmp(ope,"div")==0) printf("The qoutient on dividing %d by %d is %d\n",num1,num2,num1/num2);
    else if(strcmp(ope,"rem")==0) printf("The reminder on divindin %d by %d is %d\n",num1,num2,num1%num2);
    else printf("Invalid command only keywords available are add,sub,mul,div,rem.\n");
    goto start;
    end:
    }
    void sci()
    {
    //declaration
    char ope[3];
    int num1;
    
    start:
    
    cin>>ope;
    if(strcmp(ope,"end")==0) goto end;
    cin>>num1;
    if(strcmp(ope,"sin")==0) printf("The sin value of %d is %d\n",num1,sin(num1));
    else if(strcmp(ope,"cos")==0) printf("The cos value of %d is %d\n",num1,cos(num1));
    else if(strcmp(ope,"tan")==0) printf("The tangent value of %d is %d\n",num1,tan(num1));
    else if(strcmp(ope,"log")==0) printf("The log value of %d is %d\n",num1,log(num1));
    else printf("Invalid command only keywords available are sin,cos,tan and log.\n");
    goto start;
    end:
    cout<<"You are now leaving the scientific calculator. To return to scientific calculator mode type sci.\n";
    }
    
    void ssc()
    {
    //declaration
    char ope[3];
    int result,num1;
    
    cout<<"Enter the first value:";
    cin>>result;
    
    start:
    
    cin>>ope;
    if(strcmp(ope,"end")==0) goto end;
    cin>>num1;
    if(strcmp(ope,"add")==0) result=result+num1;
    else if(strcmp(ope,"sub")==0) result=result-num1;
    else if(strcmp(ope,"div")==0) result=result/num1;
    else if(strcmp(ope,"mul")==0) result=result*num1;
    else printf("Invalid command only available keywords are add,sub,mul,div\n");
    printf("For now the result is %d\n",result);
    goto start;
    end:
    cout<<"Now you exiting the succesive calculating mode\n";
    }
     
    Last edited by a moderator: Sep 1, 2010
  3. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    That isn't assembly language; that's C. It also won't compile due to an error on line 1 (you didn't tell the preprocess what to include).
     
  4. lionaneesh

    lionaneesh Active Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    43
    Occupation:
    Student
    Location:
    India

Share This Page