The basics of programming in c++ for beginners

Tasks and solution. С

  1. Data types, variables and constants
  2. Ввод с клавиатуры и вывод данных на экран
  3. Арифметические операции и комбинированные операторы
  4. Операторы выбора if и else в С
  5. The switch statement in C ++
  6. The for loop in C++
  7. Циклы while, do while, nested loops
  8. Two-dimensional arrays C ++
  9. Arrays in C++
  10. Functions in C++
  11. Pointers C ++
  12. A pointer to a pointer to C ++
  13. Classes in C ++

Additional collection of problems with solutions

практика программирования, задачи с решением, задачи по программированию с++, задачи по программированию C++

This page contains all of the tasks on the topics lessons, posted on our website. К каждой задаче прилагается наш вариант решения. Постарайтесь всё же решать их самостоятельно и только потом сравнивать наш исходный код со своим. “Хочешь научиться программировать – программируй”!

Больше практических заданий с решениями найдёте here.

Рекомендуем посетить Сайт для юных программистов – где вы найдете уроки по различным языкам программирования (в том числе для детей), 3D-моделированию, Linux и др.

132 thoughts on “Tasks and solution. С

  1. Site bomb , but friends, translate the tasks into your native language because it is not very clear what it is about

  2. #include

    using namespace std;

    class Date {
    public:
    int day, month, year;
    Date () {}
    Date(int day, int month, int year) {
    this->day = day;
    this->month = month;
    this->year = year;
    }
    string toString() {
    string d = “”, m = “”;
    if (day < 10) d = "0";
    if (month car_model = car_model;
    this->manufacturer = manufacturer;
    this->class1 = class1;
    this->year = year;
    this->date = date;
    }
    Print() {
    cout << "\t" << car_model << "\t" << manufacturer << "\t" << class1 << "\t" << year << "\t" << date.toString() << endl;
    }
    };

    int main() {

    Car* Cars[] {
    new Car("AE86 Sprinter Trueno", "Toyota", "\tSport car", 2001, Date(01, 01, 2006)),
    new Car("Skyline X\t", "Nissan\t", "Sport car", 2003, Date(12, 04, 2005)),
    new Car("Corvette C3 Cabriolet", "Chevrolet", "Sport car", 2000, Date(17, 05, 2002)),
    new Car("Ferrari F40\t", "Ferrari\t", "Sport car", 1969, Date(01, 06, 2017)),
    new Car("Celica\t\t", "Toyota", "\tSport car", 1999, Date(03, 03, 2004))
    };
    for (int i = 0; i manufacturer == “Toyota” && Cars[i]->date.year Print();
    }
    return 0;
    }

  3. Create an application to evaluate the user's arithmetic expression. The user enters some arithmetic expression from the keyboard. An expression can contain: (), +, -, *, /.
    The application calculates the result of the expression, taking into account the parentheses, priorities. The result is displayed on the screen. Example, if the user entered:
    5*2 + 1
    Result: 11
    If the user entered:
    5 * (2+1)

  4. Create an Application to Evaluate a User Arithmetic Expression. The user enters some arithmetic expression from the keyboard. The expression may contain: (), +, -, *, /.
    The application evaluates the result of the expression, taking into account the brackets, priorities. The result is displayed on the screen. For example, if the user entered:
    5*2 + 1
    Result: 11
    If the user entered:
    5* (2+1)

  5. Help, you are welcome!!! Very urgent!!!
    A task – Generate a new line, which includes words in ascending order of length. Find the first digital word and change its value, I divided into 100.
    Using the library

    1. Here is the answer

      #include
      #include
      #include
      #include
      #include
      #include

      int main() {
      SetConsoleOutputCP(1251);
      SetConsoleCP(1251);
      // Enter a string
      std::string inputString;
      std::cout << "Введите строку: ";
      std::getline(std::cin, inputString);

      // Splitting a string into words
      std::istringstream iss(inputString);
      std::string word;
      std::vector words;
      while (iss >> word) {
      words.push_back(word);
      }

      // Sort words by length
      std::sort(words.begin(), words.end(), [](const std::string& a, const std::string& b) {
      return a.length() < b.length();
      });

      // Finding the first digital word and changing its meaning
      for (auto& w : words) {
      if (std::all_of(w.begin(), w.end(), ::isdigit)) {
      int numericValue = std::standing(w);
      numericValue /= 100;
      w = std::to_string(numericValue);
      break;
      }
      }

      // Formation of a new line
      std::string resultString;
      for (const auto& w : words) {
      resultString += w + " ";
      }

      // Output of the result
      std::cout << "Новая строка: " << resultString << std::endl;

      return 0;
      }

      1. these are libraries
        don't forget to close the parentheses

        #include < iostream
        #include < string
        #include < algorithm
        #include < sstream
        #include < vector
        #include < windows.h

  6. Help with a C++ task
    If all units are located before the maximum element of the table, then replace the maximum table element with the number of these units

Leave a Reply

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