The basics of programming in c++ for beginners

# Tasks: Select if and else statements in c ++

After reading the lesson aboutSelect if and else statements, go to practice. As usual, I ask you to try to solve all tasks independently, and only then look at proposed us decision.

1. The first task is interesting and fairly simple. But the code will succeed long. This task came up with our teachers of computer Academy. The idea was to – how to get beginning students suffer with writing code, to scribbling was more )))  The task: The user enters the number of the 1 to 9999 (the amount of the issuance of an ATM). It should display the words entered by the amount and in the end to write the name of the currency with the correct ending. For example: 7431 – seven thousand four hundred thirty-one Dollars_, 2149 – two thousand one hundred forty-nine dollars_, 15 – fifteen dollars_, 3 – three dollars_. To solve this task you will need to use the operator % (remainder of the division). Read about it in an article, you can Arithmetic operations in C ++  . Start!

2.  The user enters the serial number of the finger. It should show its name on the screen.

3. Another challenge for yourself solutions. You must write a program, which checks the user on the knowledge of the multiplication table. The user enters two single-digit numbers. The program asks the question: the result of multiplying the first day of the second.  The user must enter a response and see on the screen is correct or not, he said,. If not– show yet and the correct result.

|

## 255 thoughts on “Tasks: Select if and else statements in c ++”

1. Ilia says:

I want to share their undertakings = D

#include
#include
using namespace std;

bool b(int x)
{
for(int i = 2; i <= 4; i )
{
if (x == i)
{
return true;
}
}
return false;
}

int main(int argc, char** argv)
{
setlocale(0,"");
int x;
do
{
cout <> x;
if ((x % 100) / 10 == 1)
{
cout << x << " Долларов\n";
}
else {
if ((x % 10) == 1)
{
cout << x << " Доллар\n";
}
else {
if (b(x % 10))
{
cout << x << " Доллара\n";
}
else
{
cout << x << " Долларов\n";
}
}
}
}
while(MessageBox(0,"Повторить?","",4) == IDYES);
return 0;
}

2. Ilia says:

cout – it std::cout
Output =|

1. Ilia says:

just use using namespace std and to better understand it, you should read about the namespace although I have not read it yet :D

3. Rus best cheater in the world, but so far only studies says:

#include
#include
using namespace std;
int main()
{
int a,b, f;
cout <> a >> b >> f;
cout << a << "*" << b << "=" << f;
if (a*b==f)
cout << " \npravilno";
else
cout << "\nnepravilno\n"<< "pravilniy otvet budet\n" << a * b ;
}

1. vasilllllllliiii says:

#include
using namespace std;
int main()
{
int a,b, f;
cin >> a >> b >> f;
cout << a << "*" << b << "=" << f;
if (a*b==f)
cout << " \npravilno";
else
cout << "\nnepravilno\n"<< "pravilniy otvet budet\n" << a * b ;
}

4. Ilya says:

int main()
{
setlocale(LC_ALL, “rus”);
int x, Y, from;
cout <> x;
cout <> Y;
z = x * Y;
cin >> from;
if (z = x * Y) cout << "вы ввели не верно";
else cout << "вы ввели верно";
}

5. GertsogVIII says:

#include
using namespace std;

int main() {
int a,b,res;
cin >> a >> b >> res;

if (a * b == nothing)
{
cout << "Congratulations, you're right"<<endl;
}
else {
cout << "you are think that " << a << "*" << b << "=" << res << "?"<< endl;
nothing a * b =;
cout << "not, you're wrong, because " << a << "*"<<b<<"="<< res;
}

return 0;
}

6. Max says:

#include
#include
#include
using namespace std;

int main()
{
int ch = 1;
do
{
srand(time(NULL));
int a, b, c, d;
a = rand() % 10;
b = rand() % 10;
c = a * b;
cout << a << " x " << b << " = ? " <> d;
if (d == c)
cout << "GJ" << endl;
else {
cout << " :( " << endl;
}

}
while (ch == 1);
system("pause");
}

7. Dmitriy says:

проверка знаний таблицы умножения
#include

using namespace std;

void main()
{
setlocale(LC_ALL, “ru”);

int a = 0,i=0;

for (a = 0; a < 3; )
{
int b, c, d, e;

cout << "введите 2 number" <> b >> c;
d = b * c;
cout << "введите результат умножение этих чмсел" <> e;
if (d == e)
a++;
else
{
i ;
}

}
cout << "Неправельных ответов = " << i << endl;

system("pause");

}

#include
using namespace std;
int main()
{
int a,b,c;
cout<<"Введите первое однозначное число"<>a;
cout<<"Введите второе однозначное число"<>b;
if(a=10)
{
cout<<"Разрешенно вводить только однозначные числа"<<endl;
return 0;
}
if(b10)
{
cout<<"Разрешенно вводить только однозначные числа"<<endl;
return 0;
}
else
cout<<"Введите результат умножения?"<>c;
if(a*b==c)
{
cout<<"Правильно!!"<<endl;
}
else
cout<<"Учи таблицу\n"<<"Правильный ответ: "<<c<<endl;
return 0;
}