The basics of programming in c++ for beginners

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

After reading the lesson about Select 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 problem 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.

Tasks: Select if and else statements in c ++

|

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

1. Nazar says:

#include
#include
#include
using namespace std;
int main()
{
setlocale (LC_ALL,”Russia”);
double x,Y,n,b;
cout<<"введи первое число"<>x;
cout<<"введи число на которое надо умножить"<>Y;
b=x*y;
cout<<x<<"*(MULTIPLY)"<<Y;
cout<<endl<<"ваш отвеееееееееееет?"<>n;
if (n!= X * y)
{
cout<<"неверно! не парься посмотри на правильный ответ";
cout<<endl<<"правильный ответ"<<endl<<b;
}
else if (n = x * y)
{
cout<<"верно! так держать";

}
return 0;
}

2. newb says:

why 47 line of code in the 1 task ?

3. Intelligence says:

#include

using namespace std;

int main()
{
setlocale(0,””);
int a,b,res,res2;
cout<<"Введите 2 целых однозначный числа"<>a>>b;
cout<<"Какой результат умножения "<<a<<" на "<<b<<" ?"<>res2;
if(res2==res)
cout<<"Все верно!!))"<<endl;
else
cout<<"Ответ не верен, правильный ответ "<<res<<endl;

}

4. Edaz1k says:

#include
#include
#include
using namespace std;
int main()
{
setlocale(LC_ALL, “Russian”);
int a, b, c;

cout<>a;
cout<>b;
cout<>c;
if (c==a*b)
else
cout<<"Не правильно! Answer: "<<a * b<<endl;
return 0;
}

5. GaGaRin says:

#include
#include
#include
#include
#include
#pragma hdrstop

//—————————————————————————

#pragma argsused
int main(int argc, char* argv[])
{
int a,b,c;
setlocale(LC_ALL, “russian_russia.1251”);
SetConsoleOutputCP(1251);
SetConsoleCP(1251);
anyTime:
cout<>a;
cout<>b;
secondTime:
cout<<a<<" * "<<b<>c;
if (a*b==c)
{
cout<<"Âåðíî! \n";
goto anyTime;
}
else
{
cout<<"Ìäà… Ooieou, áðàòèê! Io IE ÷ åćī, ïîïðîáóé au Dac! \n";
goto secondTime;
getch();
} return 0;
}

6. Alexander says:

Here is the calculator right decision.
======================================
#include

using namespace std;

int main()
{
int a , b, c, d;

cout << "Таблица умножения." << endl;
cout << "Введите 2 number." << endl;
cout <> a;
cout <> b;

cout << "Сколько будет " << a << " * " << b <> c;

d = a * b;

if(a * b == c)
{
cout << "Верно." << endl;
}
else
{
cout << "Не верно!" << endl;
cout << "Будет: " << d << endl;
}

system("pause");
return 0;
}

1. Alexander says:

That is, the multiplication tables :D

7. Alexey says:

Correct solution
#include “pch.h”
#include
using namespace std;

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

float a, b, result, c;
cout << "///////////ПРОВЕРКА НА ЗНАНИЕ ТАПЛИЦЫ УМНОЖЕНИЯ.///////////\n\n";
cout << "Введиде два числа\n";

cout <> a;

cout <> b;

cout <> c;

result = a * b;

if (c == result) {
cout << "Ответ " << c << " right" << endl;
}
else {
cout << "Ответ " << c << " не верный\n";
cout << "Верный ответ " << result;
}
cout << endl << endl;
return 0;
}

1. Alexey says:

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

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

float a, b, result, c;
cout << "///////////ПРОВЕРКА НА ЗНАНИЕ ТАПЛИЦЫ УМНОЖЕНИЯ.///////////\n\n";
cout << "Введиде два числа\n";

cout <> a;

cout <> b;

cout <> c;

result = a * b;

if (c == result) {
cout << "Ответ " << c << " верный" << endl;
}
else {
cout << "Ответ " << c << " не верный\n";
cout << "Верный ответ " << result;
}
cout << endl << endl;
return 0;
}

8. Jaroslav says:

#include

using namespace std;

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

int x;
int y;
int z;

cout<>x;
cout<>Y;

cout<>from;
if(z==x*y)
cout<<from<<" это верный ответ ";
else
cout<<"Нет. Верный ответ: "<<x*y;
}