The basics of programming in c++ for beginners

Tasks: arithmetic operations in C ++

If you have already read the articleArithmetic operations in C ++ you can begin to practice.

1. Common task:  Given the four-digit number (for example 5678), display the numbers in reverse order of which is the number of member. That is, we should see on the screen 8765. Tip: to take from among the individual numbers, should be applied to the modulo 10.

2. The site of almost any commercial bank, you can find the so-called Deposit calculator, which allows people to, not wishing to go into the formula for calculating interest rates, to know how much they will receive. To do this, they just fill in certain fields, press the button and see the result. This is a simple program, which has already been able to write each one of you. So, a task: The user enters the amount of the deposit and the number of months of keeping money in the bank. It is necessary to calculate and show the screen profit from the deposit in a month,  for the entire term of the deposit, and the total amount payable at the end of the period.  Currency let it be – U.S. dollar. Interest rate – 5% APR.  The formula for calculating percent per month–                      SumDeposit * (interest rate / 100)  / daysperyear * dayspermonths.

Perhaps you have any questions about the solution of tasks – ask them in the comments!

151 thoughts on “Tasks: arithmetic operations in C ++

  1. #include
    using namespace std;
    int main(){
    double dep, months, percent;
    cout <> dep;
    cout <> percent;
    //cout ;
    cout <> months;
    cout << "Расчет" << endl;
    cout << "===========================================================" << endl;
    dep /= 100;
    dep *= percent;
    dep /= months;
    cout << "Ежемесячные проценты: " << dep << " долларов" << endl;
    dep *= months;
    cout << "Общая сумма депозита за весь период: " << dep;
    }

  2. Horrible, commenting didn't convey all my code, in the end you will understand what is there…(

  3. # ez gg wp
    #include
    using namespace std;
    int main()
    {
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    you e = 0;
    int f = 0;
    cout << "vvedite chetirehznachnoe chislo" <> a;
    while (a > 9999) {
    cout << "error" << endl;
    return 0;
    }
    while (a < 1000) {
    cout << "error" << endl;
    return 0;
    }
    b = a / 1000;
    b = b % 10;
    c = a / 100;
    c = c % 10;
    d = a / 10;
    d = d % 10;
    and = a;
    and = and % 10;
    cout << e << d << c << b;
    return 0;
    }

  4. so as not to constantly suffer and not write through
    //cout << mainNumber % 10;
    mainNumber /= 10; //////////////several times, namely as many times as a significant number, and do this through the for////////////////////////////////
    ///////after half an hour, the tormented doper himself/////////////////
    #include
    using namespace std;

    int main() {
    setlocale(LC_ALL, “rus”);

    int mainNumber = 56786895154;
    cout << "дано целое число:" << mainNumber << endl;
    cout << "число на изнанку:";

    for (int i = 0; i < 11; i ) {
    cout << mainNumber % 10;
    mainNumber /= 10;
    }

    cout << endl << endl;

    return 0;

    }

    1. //You can still improve this way after half an hour it came to mind again ))))

      #include
      using namespace std;

      int main() {
      setlocale(LC_ALL, “rus”);
      int Number; // variable to store how many digits you enter
      int MainNumber;
      cout <> MainNumber;
      cout <> Number;

      cout << "число на изнанку: ";

      for (int i = 1; i < Number; i ) {

      cout << MainNumber % 10;
      MainNumber /= 10;
      }

      cout << MainNumber;

      cout << endl << endl;

      return 0;
      }

      1. // at the top case an erroneous code
        #include
        using namespace std;

        int main() {
        setlocale(LC_ALL, “rus”);
        int Number; //variable to store how many digits you enter
        int MainNumber;
        cout <> MainNumber;
        cout <> Number;

        cout << "число на изнанку: ";

        for (int i = 1; i < Number; i ) {

        cout << MainNumber % 10;
        MainNumber /= 10;
        }

        cout << MainNumber;

        cout << endl << endl;

        return 0;
        }

      2. To not take a steam bath with unnecessary variables. You can loop for any significant number

        do {
        cout << MainNumber % 10;
        MainNumber /= 10;
        } while (MainNumber);

  5. #include
    #include
    using namespace std;
    int main()
    {
    setlocale(LC_ALL, “RUS”);
    short int x;
    define PI(“Введите первое число: “);
    cin >> x;
    define PI(“Result: %d%d%d%d”, x % 10, (x / 10) % 10, (x / 100) % 10, (x / 1000) % 10);
    }

    1. #include
      #include
      using namespace std;
      int main()
      {
      setlocale(LC_ALL, “RUS”);
      int x;
      define PI(“Введите первое число: “);
      cin >> x;
      define PI(“Result: “);
      do
      {
      cout << x % 10;
      x /= 10;
      } while (x);
      }

  6. #include
    #include
    using namespace std;
    #define CC cout << "Bug" <> dep;
    define PI(“Введите количество месяцев: “);
    cin >> mou;
    define PI(“Enter interest rate: “);
    cin >> protcent;
    prOneMou = dep * (protcent / 100.0) / 365.0 * 30.0;
    define PI(“\n\n—————- Calculation —————-\nn%d * (%d / 100) / 365 * 30 = %d Rub nInterest for the entire term: %d RubnTotal you will get: %d Rubn”, dep, protcent, prOneMou, prOneMou * mou, (prOneMou*mou)+dep);
    define PI(“It will work out in a month(from percent): %d Rubnn—————- At compound interest —————-\n”, prOneMou);

    for (int i = 1; i <= mou; i )
    {
    prOneMou = dep * (protcent / 100.0) / 365.0 * 30.0;
    dep += prOneMou;
    }
    define PI("Итого получите: %d Rub\n", dep);
    }

  7. #include
    using namespace std;
    //First task
    int main()
    {
    int a;
    cin >> a;
    while (a != 0) {
    cout << a % 10;
    a /= 10;
    }
    return 0;
    }

  8. I did that
    #include
    #include
    #include

    using namespace std;

    int main() {

    setlocale(0, “”);

    int x;

    bot:

    cout << "-Сколько символов будет в вашем числе?" <> x;

    int nums;
    cout << "-Ведите число а мы сделаем его на изнанку: " <> nums;

    for (int a = 0; a < x – 1; a++) {
    cout << nums % 10;
    numbers /= 10;
    }

    cout << nums;

    return 0;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *