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. tags in the code does not correctly display some reason.

    #include
    using namespace std;

    int main()
    {
    int a;
    cout <> a;
    cout << a << a/10 << a/100 << a/1000 << endl;
    return 0;
    }

  2. #include
    using namespace std;

    int main()
    {
    int a;
    cout <> a;
    cout << "Your mirror namber is:";
    for (int x = 1; x <= a; x++) // cycle allows to draw in the return line, any number entered
    {
    cout << a % 10;
    a /= 10;
    };

    //int b = a % 10, c = ((a-b) % 100)/10, d = ((a-b-c) % 1000)/100, f = ((a-b-c-d) % 10000)/1000; (Mathematics embodiment only for 4-digit number)
    //cout << "Mirror namber is:" << b << c << d << f;

    system("pause");
    return 0;
    }

      1. Nothing strange:
        1. Do not write your comments in the code!
        2. Comments are not for…
        3. And your code here no one needs.

  3. tell ,you are welcome, why at the end of the program 2 fold “endl;” After all ,if I want to go to a new line only once , he should take it only once , but for some reason he does not perceive it at all. Only if the double write endl;

  4. The task №1 there is a much easier way to!
    #include
    using namespace std;

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

    int a1 = 5;
    int a2 = 6;
    int a3 = 7;
    int a4 = 8;

    cout << "Число наоборот:" << a4 << a3 << a2 << A1 << endl;

    system("pause");
    return 0;
    }

    1. You are a fool…
      This is a joke and! We need to do a certain number of alternating contrary, Your version of this is the task for the first lesson will!

  5. In calculating percent in the second assignment gives 0.

    1. Ты разобрался с этим вопросом?
      Как я поняла, какие-то есть определённые нюансы в работе с типом данных float.

    2. Если вдруг ты ещё не решил этот вопрос.

      Делимое число 5, в нашем случае это процентная ставка, указано у тебя как целочисленное (int). чтобы программа заработала, достаточно задать ему тип данных float

    3. У тебя в целом код был корявый, я немного подправила

      #include “stdafx.h”
      #include
      using namespace std;

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

      float deposite = 0;//deposit amount
      int value_of_month = 0;//количество месяцев
      float profit = 0;//profit per month
      int Day_In_Month = 30;
      int Day_In_Year = 365;
      float percent_per_year = 5;

      cout <> deposite;
      cout <> value_of_month;

      cout << endl;

      cout << "Годовой процент с депозита равен " << percent_per_year << "%" << endl;

      cout << endl;

      profit = deposite * (percent_per_year / 100) / Day_In_Year * Day_In_Month;
      cout << "Прибыль в месяц с депозита " << profit << endl;
      profit *= value_of_month;
      cout << "Прибыль за весь срок депозита " << profit << endl;
      profit += deposite;
      cout << "Сумма выплаты в конце срока " << profit << endl;

      cout << endl;
      system("pause");
      return 0;
      }

  6. первая задача код глупый. можно было через цикл сделать и еще чтобы пользователь сам вводил числа которые хочет развернуть

    #include
    #include
    #include
    #include

    using namespace std;
    int main(int argc, char const *argv[]) {

    int value;
    cout <> value;
    while (value !=0)
    {
    cout << value % 10;
    value /= 10;
    }
    return 0;
    }

  7. первая задача код глупый. можно было через цикл сделать и еще чтобы пользователь сам вводил числа которые хочет развернуть

Leave a Reply

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