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.
Show code
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
usingnamespacestd;
intmain()
{
setlocale(LC_ALL,"rus");
intmainNumber=5678;
cout<<"Дано целое число: "<<mainNumber<<endl;
cout<<"Число наизнанку: ";
// остаток от деления четырехзначного числа 5678 на 10
cout<<mainNumber%10;// 5678 % 10 = 8
// далее делим mainNumber на 10 и записываем в переменную
// так как тип переменной int, дробная часть отбросится
// и mainNumber будет равен 567 (а не 567,8)
mainNumber/=10;
// показываем остаток от деления 567 на 10 на экран
cout<<mainNumber%10;
mainNumber/=10;
cout<<mainNumber%10;
mainNumber/=10;
cout<<mainNumber%10;
mainNumber/=10;
cout<<endl<<endl;
return0;
}
Result:
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.
int main () { float x, from, t, k; int y = 30, g, c, j; cout<>g; if((g%4==0&&g0==0)&&g@0!=0) c=365; else c=366; cout<>x; cout<>j; z=x*(((5/100)/c)*(j * y)); t=z*j; k=x+t; cout<<"Profit per month:"<<from<<endl; cout<<"Profit for the whole term:"<<t<<endl; cout<<"Profit to pay for whole term:"<<k; return 0; } prompt, what's wrong? I have for 0 produces profits for the month and for the entire period, and turns, earnings, which must receive the investor of the amount, which he put.
int main() { setlocale(LC_ALL, “rus”); float depSumm; //Сумма депоита float srokVkl; //Срок вклада float summFinal; //Прибыль за весь срок депозита float summMonth; //Прибыль за месяц
cout <> depSumm; cout <> srokVkl;
summMonth = (depSumm * 0.05) / 12; //Сумму депозита умножаем на пять процентов и делим на 12 months summFinal = summMonth * srokVkl; //Сумму за месяц умножаем на срок вклада
cout << "Прибыль за месяц: " << summMonth << "\nПрибыль за весь срок депозита: " << summFinal; return 0; }
so it is not a lesson in cycles and have not even gone yet…
My 2
I do not quite understand the number of days, therefore I made easier:
#include
/*Something like this*/
using namespace std;
int main()
{
cout << "——Working with the remainder——" << endl;
int num = 0;
cout <> on one;
cout << "Чатыре: " << on one % 10 << endl;
cout << "Три: " << on one / 10 % 10 << endl;
cout << "Два: " << on one /100 % 10 << endl;
cout << "Один: " << on one /1000 % 10 << endl;
cout << "________End_________" << endl;
return 0;
}
#include
using namespace std;
int main ()
{
float x, from, t, k;
int y = 30, g, c, j;
cout<>g;
if((g%4==0&&g0==0)&&g@0!=0)
c=365;
else c=366;
cout<>x;
cout<>j;
z=x*(((5/100)/c)*(j * y));
t=z*j;
k=x+t;
cout<<"Profit per month:"<<from<<endl;
cout<<"Profit for the whole term:"<<t<<endl;
cout<<"Profit to pay for whole term:"<<k;
return 0;
}
prompt, what's wrong?
I have for 0 produces profits for the month and for the entire period, and turns, earnings, which must receive the investor of the amount, which he put.
Specifically task postavte.
and all have already decided))
Guys,where it is administered?
#include
using namespace std;
int main()
{
setlocale(0, “”);
Brick Mannumbr;
int outnNumber=0;
cin >> mainNumber;
cout << mainNumber <<'\n';
while (mainNumber)
{
outnNumber*=10;
Outnnumbr + = Mannumbr 10%;
mainNumber /= 10;
}
cout << outnNumber << '\n';
system ("pause");
return 0;
}
#include
using namespace std;
int main() {
setlocale(LC_ALL, “rus”);
float depSumm; //Сумма депоита
float srokVkl; //Срок вклада
float summFinal; //Прибыль за весь срок депозита
float summMonth; //Прибыль за месяц
cout <> depSumm;
cout <> srokVkl;
summMonth = (depSumm * 0.05) / 12; //Сумму депозита умножаем на пять процентов и делим на 12 months
summFinal = summMonth * srokVkl; //Сумму за месяц умножаем на срок вклада
cout << "Прибыль за месяц: " << summMonth << "\nПрибыль за весь срок депозита: " << summFinal;
return 0;
}