The basics of programming in c++ for beginners

Tasks: Data types, variables and constants

Here are collected the task to the article Data types, variables and constants. Try to solve problems on their own and only need to look at the decision. So you will learn much faster programming fundamentals.

1. Declare variables with which you can calculate the total amount of the purchase of several products. For example a chocolate bar, coffee and packets of milk.

2. Declare three variables of type int, and the first to assign a numeric value, the second variable is the first variable increased by 3, and the third variable is equal to the sum of the first two.

3. Declare variables, to count the total number of objects for the table. for example cups, the same number of saucers and spoons.

122 thoughts on “Tasks: Data types, variables and constants

  1. #include

    int main() {
    using namespace std;

    int cups;
    int spoon;
    int saucers;

    cout << "Введите кол-во чашек: " <> cups;

    spoon = saucers = cups;

    float sum;

    sum = (cups + spoon + saucers);

    cout << "Общее кол-во предметов: " << sum << endl;

    return 0;
    }

Leave a Reply to Ruslan Cancel reply

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