+ 2
can you write a program calculate the (+; - ; % ; * ;/;) of 3 variable x,y,z with you progrmming language ?!
let's start !!!
6 Réponses
+ 10
Allright, this is a good coding challenge
+ 6
There are plenty attempts at calculators here in SoloLearn, just search for them. In fact there are so many, this challenge isn't even really a challenge.
+ 5
#include <iostream>
using namespace std;
int main (void){
//two input and one output
int a, b, c;
char op; //for operation + - / *
//Read values
cout<<"Enter first value: "; cin>>a;
cout<<"Enter second value: "; cin>>b;
//Read Operator
cout<<"Enter operation (+ - * / %): "; cin>>op;
c=0;
switch (op){
case '/':
if (b==0){
cerr<<"Runtime Error: Division by zero is not possible.\nExiting Program";
return -1;
}
c = a / b; break;
case '*':
c = a * b; break;
case '+':
c = a + b; break;
case '-':
c = a - b; break;
case '%':
c = a % b; break;
default:
cout<<"Invalid operation"; return -1;
}
cout<<"Result = "<<c;
}
+ 3
good work Davender
+ 2
good work Davender
+ 1
just do it