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(int argc, char** argv) {
    setlocale(LC_ALL, “rus”);
    int startNumber = 8765;

    cout << "Âûâåñòè â îáðàòíîì ïîðÿäêå öèôðû ÷èñëà 8765\n";

    cout << start number % 10; //âûâîäèì ïîñëåäíåå ÷ Enei
    start number / = 10; //I íà ÷ ÷ àëüíîãî Enea îòñåêàåì ïîñëåäíþþ öèôðó, ïîëó÷àåòñÿ 876
    cout << start number % 10; //IO 876 âûâîäèì ïîñëåäíåå ÷ Enei, etc.
    start number / = 10;
    cout << start number % 10;
    start number / = 10;
    cout << start number % 10;
    start number / = 10;
    return 0;
    }

  2. Write a program, which takes the value entered in pounds to kilograms (1 £ - 405.9 gram). It should bring the number of hours and kilo gram.
    Example program:

    Enter your weight in pounds –> 3.5

    3.5 pound - a 1kg 420hr.

    How to write okremokilkist kg and g

    1. This approach, kg- is the integer part of the division, Gramm- this residue, like that
      so, only a part of dividing and dividing negative integer part output separately

  3. in making the code is not correct (It displays the exact value is not) and a long…

    Here's my version!

    #include
    using namespace std;
    int main()
    {
    setlocale(LC_ALL, “Russian”);
    int a, d;
    float b, c, f;
    cout <> a;
    cout <> d;
    b = (a * 0.05) / d;
    cout << "Прибыль за месяц-" << b <<endl;
    c = (b * d);
    cout << "Ваша прибыль за весь срок-" << c <<endl;
    f = c + a;
    cout << "Итоговая сумма к выплате (U.S. dollar)-" << f <<endl;
    }

  4. #include
    using namespace std;

    int main() {
    int b; //number of digits
    int c; //your number
    cout<<"Enter quantity of numbers you need"<>b;
    cout<<"Enter your number"<>c;
    cout<<"Original number : ";
    cout<<c<<endl; //oiznachalnoe number
    cout<<"Inverted number : ";
    for (int a = 0; a < b; a++){
    cout<<c; //number of shares
    c /=10; //overwrites the variable
    };
    return 0;
    }

  5. I did
    #include “stdafx.h”
    #include “conio.h”
    #include
    #include

    using namespace std;

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

    float stavka = 5, stavkaMon, deposit, profit, sum, time;
    cout <> sum;
    cout <> time;

    stavkaMon = sum / 100 * 5 /12;
    profit = stavkaMon * time;
    deposit = profit + sum;

    cout << "Идет расчет………………………" << endl;
    cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
    cout << "\n" << endl;

    cout << "Количество процентов в месяц – " << stavkaMon << "$" << endl;
    cout << "Количество процентов за указанный срок – " << profit << "$" << endl;
    cout << "Общая сумма выплаты " << deposit << "$" << endl;

    _getch();
    return 0;
    }

  6. This is a shorter way to
    #include
    #include

    using namespace std;

    int main(){
    setlocale(LC_ALL,”Russian”);
    int reverb;

    cout <> reverb;
    cout << reverb << (reverb0)/10 << (reverb00)/100 << reverb/1000;

    return 0;
    }

  7. // Example program
    #include
    #include
    // SumDeposit * (interest rate / 100) / daysperyear * dayspermonths.
    int main()
    {
    int day_year, day_mounse, day_dep; // interest rate, days a year, days per month, shall indicate that the
    float proc_stavka, summ_dep, dep_mes, dep_year, summ_all; // The amount of, the amount of the month, the amount for the year, the entire amount
    // we set the value
    proc_stavka = 0.05;
    day_year = 365;
    day_mounse = 30;
    // Data input
    std::cout << "Enter summ of dep: " <> summ_dep;
    std::cout << "Enter time of dep: " <> day_dep;
    // interest statement
    dep_mes = summ_dep * proc_stavka / day_year * day_mounse; // Per month
    dep_year = dep_mes * 12; // In year
    summ_all = dep_mes * day_dep; // the whole period

    //Output on display

    std::cout << "Сумма за месяц: " << dep_mes << " $" <<std::endl;
    std::cout << "Сумма за год: " << dep_year << " $" <<std::endl;
    std::cout << "Вся сумма: " << summ_all << " $" << std::endl;

    return 0;
    }

  8. #include
    #include
    using namespace std;
    int main()
    {
    setlocale(LC_ALL, “rus”);
    float sumdep = 0;
    int amofmon = 0;
    float prof = 0;
    int dng = 365;
    int dnm = 30;
    float procs = 5;
    cout<>sumdep;
    cout<>amofmon;
    prof = sumdep * (processes / 100) / dng * dnm;
    cout<<"Прибыль с деп. per month: "<<prof<<"$"<<endl;
    prof *= amofmon;
    cout<<"Прибыль с деп. for the entire period: "<<prof<<"$"<<endl;
    cout<<"Общая сумма: "<<sumdep+prof<<"$"<<endl;
    return 0;
    }

Leave a Reply

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