NXC Calculator from C
 Software and Programming Related   Started by Felinskii S   2015-09-11 12:47:02 -04:00   Comments: 1    Viewed: 462

  1. Felinskii S
    Felinskii S Member

    Postby felinski » Sun Mar 29, 2015 10:45 am

    Hey, is anyone good at C and NXC? I want to make a calculator in NXC(or just a working calc for the NXT, really), and I have made one in C.
    This is what is looks like:


    # include
    int main()
    {
    char o;
    float num1,num2;
    printf("Enter operator either + or - or * or divide : ");
    scanf("%c",&o);
    printf("Enter two operands: ");
    scanf("%f%f",&num1,&num2);
    switch(o) {
    case '+':
    printf("%.1f + %.1f = %.1f",num1, num2, num1+num2);
    break;
    case '-':
    printf("%.1f - %.1f = %.1f",num1, num2, num1-num2);
    break;
    case '*':
    printf("%.1f * %.1f = %.1f",num1, num2, num1*num2);
    break;
    case '/':
    printf("%.1f / %.1f = %.1f",num1, num2, num1/num2);
    break;
    default:
    /* If operator is other than +, -, * or /, error message is shown */
    printf("Error! operator is not correct");
    break;
    }
    return 0;
    }

    Now I would like to convert this code to NXC or just make it usable on the intelligent brick. I'm using NXT 2.0 for the record.
    Felinskii S, 2015-09-11 12:48:01 -04:00
  2. (You must log in or sign up to post here)

Log in | Sign up
Tems & Conditions!
Help!