I am having issues with creating a menu option for the ADDITION SUBTRACTION MUL
ID: 3772354 • Letter: I
Question
I am having issues with creating a menu option for the ADDITION SUBTRACTION MUL AND DIVISION.
Also, any suggestions on how i can fix this so i can show each function seperately ?
#include "stdafx.h"
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float op1, op2, result; // GET TWO NUMBERS
printf("ENTER TWO NUMBERS : ");
cin >> op1;
cin >> op2;
cout << "op1= ", op1;
cout << "op2 = ", op2;
system("pause");
return 0;
}
// POP OPERANDS FROM STACK
//STORE THE RESULT IN STACK
/*
_asm
{
fld % 1;
fld % 2;
fadd;
fstp % 0; ":" = G" (RESULT) : "G" (op1), "g" (op2));
}*/
/*
float op1, op2, result; // GET TWO NUMBERS
printf("ENTER TWO NUMBERS : ");
scanf("%f%f", &op1, &op2);
_asm
{
fld % 1;
fld % 2;
fsub;
fstp % 0; ":" = G" (RESULT) : "G" (op1), "g" (op2));
printf Subtraction of %f, %f = %f ", op1 op2, result ;
}
float op1, op2, result; // GET TWO NUMBERS
printf("ENTER TWO NUMBERS : ");
scanf("%f%f", &op1, &op2);
_asm
{
fld % 1;
fld % 2;
fsub;
fstp % 0; ":" = G" (RESULT) : "G" (op1), "g" (op2));
printf Subtraction of %f, %f = %f ", op1 op2, result ;
}
printf("subtract %d, %d", op1, op2, );*/
Explanation / Answer
For your convenience you can use this program as well.
________________________________________________________________________________________
Output:
Enter operator either + or - or * or divide : - Enter two operands: 3.4 8.4 3.4 - 8.4 = -5.0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.