C++ Program to implement Calculator functions for : +, -, *, /, ^
#include <iostream.h>
#include <conio.h>
float inputOne, inputTwo, answer;
char operator_, yn;
int main()
{
textcolor(LIGHTBLUE);
while (yn != 'n')
{
clrscr();
cout << "First number + - / * ^ second number\n";
cin >> inputOne >> operator_ >> inputTwo;
if (operator_ == '+')
answer = inputOne + inputTwo;
if (operator_ == '-')
answer = inputOne - inputTwo;
if (operator_ == '*')
answer = inputOne * inputTwo;
if (operator_ == '/')
{
if (inputTwo == 0)
{
cout << "Cannot divide by 0";
}
else
answer = inputOne / inputTwo;
}
if (operator_ == '^')
{
answer = inputOne;
for (int i=2; i<=inputTwo; i++)
answer = answer * inputOne;
}
cout << endl;
cout << inputOne << " " << operator_ << " ";
cout << inputTwo << " = " << answer;
cout << "\n\nSolve another? <yn> ";
cin >> yn;
cout << "\n";
}
return 0;
}
Related Posts : C++ Programs
1 comments:
How to get from casino to valet at the valet bar - TrickTactoe
valet 에볼루션 at the valet bar - This valet bar is located right next to the valet bar. It is located 메이저 토토 사이트 right behind the 벳 인포 스포츠 토토 분석 벳피스트 bar 다음 드 entrance. 토토 배트맨
Post a Comment