The basics of programming in c++ for beginners

Tasks: Data input and output

In a previous articleData output on the screen and in theentray data from the keyboard We examined in detail this topic. It's time to practice – because we have a lot of work, to develop certain skills, needed a programmer and develop their logical thinking quietly.

1. Create 4 variables with different types of data and ask the user to enter values ​​in them. After entering the, display them on the screen.

2. Create 5 variables of type char, ask the user to enter a word of five letters, and show these symbols (the word) the screen. (Enter characters in Latin, tk. cyrillic is displayed incorrectly. Why? This will be discussed in one of our next lessons)

3. Display the text in this form:

data display

4. The user must enter 2 numbers. You need to show on the screen the product of these numbers, sum and difference. Show the same arithmetic mean of these numbers entered.


Questions to ask in the comments.

74 thoughts on “Tasks: Data input and output

  1. Guys, and how to create several source files in one project in Visual Studio ? When I just add the class and use the main function again { } , the compiler throws an error due to the double use of m a i n ?

  2. 1.
    #include

    using namespace std;

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

    char 1;

    char 2;

    char 3;

    char 4;

    std::cout << "Введите 4 any characters: " <> 1 >> 2 >> 3 >> 4;

    std::cout << "Вы ввели: << 1 << 2 << 3 << 4 << endl;

    return 0;
    }

  3. 2.
    #include

    using namespace std;

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

    char symbol1;

    char symbol2;

    char symbol3;

    char symbol4;

    char symbol5;

    std::cout << "Введите слово из 5-и букв: " <> symbol1 >> symbol2 >> symbol3 >> symbol4 >> symbol5;

    cout << "Вы ввели: << endl;
    std::cout << symbol1 << symbol2 << symbol3 << symbol4 << symbol5 << endl;
    return 0;
    }

  4. #include
    using namespace std;

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

    cout << "\tА почему в ресторане ей никогда не нравится то,\n";
    cout << "\tчто заказала она, and always like it, what did I order?\n";
    cout << "\tИ она начинает есть у меня из тарелки. I tell her:\n";
    cout << "\t\<\\>. Она говорит\<\<What for?\n";
    cout <\>. И съедает половину\n”;
    cout << "\t\t\\\\к.ф.\"О чём говорят мужчины\" \\\\\n";

    return 0;
    }

  5. #include
    using namespace std;

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

    int Beeer = 0;
    int Beeer2 = 0;

    cout <> Beer;
    cout <> Beeer2;

    cout << endl << endl;
    cout << "Первое число: "<< Beer<<endl;
    cout << "Второе число: " << Beeer2 << endl;

    cout << endl << endl;
    cout << "Сумма чисел: " << Beer + Beeer2 << endl;
    cout << "Произведение числа: " << Beeer2 * Beer<< endl;
    cout << "Разница чисел: " << Beer – Beeer2 << endl;
    cout << "Среднее арифметическое чисел: " << (Beeer2 + Beer) / 2 << endl;

    return 0;
    }

  6. I watched the video for the lesson and shortened the code:
    #include
    using namespace std;

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

    float Beeer, Beeer2;

    cout <> Beer >> Beeer2;

    cout << endl << endl;
    cout << "Первое число: "<< Beer <<endl << "Второе число: " << Beeer2 << endl << endl;

    cout << "Сумма чисел: " << Beer + Beeer2 << endl;
    cout << "Произведение числа: " << Beeer2 * Beer<< endl;
    cout << "Разница чисел: " << Beer – Beeer2 << endl;
    cout << "Среднее арифметическое чисел: " << (Beeer2 + Beer) / 2 << endl;

    return 0;
    }

  7. #include

    using namespace std;

    int main() {
    setlocale(0, “RU”);
    char z = ‘ ‘;
    int a;
    float b;
    double c;
    bool d;
    cout <> a;
    cout <> b;
    cout <> c;
    cout <> d;
    cout << a << from << b << from << c << from << d;
    return 0;
    }

  8. #include

    using namespace std;

    int main() {
    cout << "что-то там «привет» что-то там «пока» что-то там?,?,? // \"прив\" //";
    return 0;
    }

Leave a Reply

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