## A simple calculator for adding and subtracting in c++

In this post, I write a code about very simple calculator in c++. Actually it is the problem in e-olymp.com

If you're not familiar with this website then you can go below link:

Input is in this form :

### x+5=2  or 1+x=4  or  1+4=x

In the output we give the value of x.

It has very simple solution. That's why i give there only code and when you read this code line-by-line you easily understand it     :)

Solution:

`#include<iostream>`
`#include<string>`
```
using namespace std;```
```
int main(){

string statement;```
```    cin>>statement;
int last_number = 0;```
```
if(statement[statement.length()-1] == '0' || statement[statement.length()-1] == '1'```
`        || statement[statement.length()-1] == '2' || statement[statement.length()-1] == '3'`
`            || statement[statement.length()-1] == '4' || statement[statement.length()-1] == '5'`
`                || statement[statement.length()-1] == '6' || statement[statement.length()-1] == '7'`
```                    || statement[statement.length()-1] == '8' || statement[statement.length()-1] == '9'){
last_number = (int)statement[statement.length()-1] - 48;```
```    }

if(statement=='+' && statement=='x'){
int first_number=0, x;```
```        first_number = (int) statement - 48;
x = last_number - first_number;```
```
cout<<x;```
```    } else if(statement=='-' && statement=='x'){
int first_number=0, x;```
```        first_number = (int) statement - 48;
x = first_number - last_number;```
```
cout<<x;```
```    } else if(statement=='x' && statement=='+'){
int first_number=0, x;```
```        first_number = (int) statement - 48;
x = last_number - first_number;```
```
cout<<x;```
```    } else if(statement=='x' && statement=='-'){
int first_number=0, x;```
```        first_number = (int) statement - 48;
x = last_number + first_number;
cout<<x;```
```    } else if(statement[statement.length()-1]=='x'){
int first_number, second_number,x;
first_number = (int) statement - 48;
second_number = (int) statement - 48;
if(statement=='+'){
x = first_number + second_number;```
```        } else if(statement=='-'){
x = first_number - second_number;```
```        }

cout<<x;```
```    }

return 0;
}```
Number of page views: ### SQL - Part 1

SQL tutorial from scratch -- Part 1

Introduction

Before going deep dive into in SQL I want to explain the main purpose of DB(database).
Suppose we have large amount of data (for example it would be the students in the same class), and we want to create some website which is give us all information about them. How we do it. Of course using database.Maybe you ask yourself questions: "I can store them in file or array". Yes you is exactly right. But imagine you have large amount of data and if you store them in file or array your program/website will work very hard. Now let's visualize databases:

As we can see it is one of the basic db type which is store title, release_year, length and replacement_cost.

Don't worry about DB if you don't understand them very well. Our next paragraphs will explain it more accurately and also I try to add some important images.

"Yes I know that right …

### Java Proqramlashdirma Dili

1) Dostlar bu blogda java proqramlasdirma dili haqqinda melumat verecyik

Java proqramlasdirma dili high level programming language sinfine daxildir bu proqramlasdirma dili muxtelif platformalarda calisirki bu da onun ustun cehetlerinden biridir. Java proqramladirma diline oxshar dillere misal olaraq C, C#, C++ misal gostermek olar. Bunu qeyd etmek kifayetdir ki eger siz sadaladigim dillerden hec olmasa birini mukemmel bilsez o biri diller sizin ucun su kimi asan olar. Yeni esas sizin OOP den basiniz cixmalidir birdeki alqoritmleri derinden menisemek lazimdir. Eger alqoritmleri derinden menimsemek isteyirsinizse sizin sade riyazi biliklerden basinziz cixmalidir eks halda alqoritme geldikde sizin ucun cetin ola biler. Lakin size sad xeberim var, hetta riyzi bilikleriniz o qeder de yaxi deyilse de siz oz alqortim biliklerinizi tekmillesdir bilersiniz bunun ucun her movzudaki alqoritmlere aid coxlu mesele, misal hell etmek ve partnyorunuzla muzakire etmelisiniz . Bu muzakire etmek meseles…