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. Second)) Working

    #include

    main()
    {
    int a, b, c;
    printf(“Enter the number ‘x’: “);
    scanf(“%d”, &a);
    b = a * 3; c=a+b;
    printf(“%d, %d * 3 =% d, %d +% d =% d”, a, a, b, a, b, c);
    getch();
    }

  2. #include

    using namespace std;

    int main(){

    setlocale(LC_ALL, “rus”);

    double Chokolat;
    double maslo;
    single text;
    double x,Y,from,sum;
    double cena_chokolat = 0;
    double cena_maslo = 0;
    double cena_testo = 0;

    cout <> x;
    cout <> Y;
    cout <> from;
    cout <> cena_chokolat;
    cout <> cena_maslo;
    cout <> cena_testo;
    Chokolat = x * cena_chokolat;
    maslo = y * cena_maslo;
    text = z * cena_testo;
    cout << "\a\a\a\a\a\a" << endl;
    cout << " \Chocolate t left in the amount of = " << Chokolat << " rub " <<endl;
    cout << " \t the oil remains in the amount of = " << maslo << " rub " << endl;
    cout << " \t Test for the amount remaining = " << text << " rub " << endl;
    sum = Chokolat + maslo + text;
    cout << " \t The sum of all goods = " << sum << " rub " << endl;

    return 0;
    }

  3. 2 задача короче сделал, зачем длинные слова?)

    1. количество шоколада??
      и как это понимать русскому человеку?)

      1. Скорее всего плиток шоколада. И вообще зря придираешься.

  4. #include
    #include

    using namespace std;
    int main()
    {
    setlocale(LC_ALL, “Russian”);
    int a, b, c;
    cout << "Введите а: " <> a;
    b = a + 3;
    c = a + b;
    cout << "b равна: " << b << " " << "c равна: " << c << endl;
    system("pause");
    return 0;

    }

Leave a Reply

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