Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Примеры задач.docx
Скачиваний:
0
Добавлен:
01.03.2025
Размер:
188.92 Кб
Скачать

Завдання № 15

Яке значення буде роздруковано в разі виконання наступної програми

#include <stdio.h>

int

main(void)

{

int a =10, b =5, c =15, max =0;

max =a;

if (max > b)

max = b;

if (max > c)

max = c;

printf("max =%d\n", max);

printf("variable:");

if(a==max)

printf("a");

if(b==max)

printf("b");

if(c==max)

printf("c");

printf("\n");

return 0;

}

Завдання № 16

Яке значення буде роздруковано в разі виконання наступної програми

#include <stdio.h>

#include <math.h>

int

main(void)

{

double a =10, b = 5, c =15, average =0;

average = (( a + b + c) / 3);

printf("average = %g\n" , average);

if ( a < average)

printf(" a is less than average\n");

else if ( a > average)

printf(" a is greater than average\n");

else if ( a == average)

printf(" a is egual to average\n");

if ( b < average)

printf(" b is less than average\n");

else if ( b > average)

printf(" b is greater than average\n");

else if ( b == average)

printf(" b is equal to average\n");

if ( c < average)

printf(" c is less than average\n");

else if ( c > average)

printf(" c is greater than average\n");

else if ( c == average)

printf(" c is equal to average\n");

return 0;

}

Завдання № 17

Яке значення буде роздруковано в разі виконання наступної програми

#include <iostream.h>

main()

{

int int1 = 1, int2 = 2;

long long1 =1 , long2 = 2, long3 = 3, long4 = 4, long5 = 5;

long1 = int1 + int2;

long2 = int1 - int2;

long3 = int1 * int2;

long4 = int1 / int2;

long5 = int1 % int2;

cout << long1 << "\n";

cout << long2 << "\n";

cout << long3 << "\n";

cout << long4 << "\n";

cout << long5 << "\n";

cout << "\n\n";

return 0 ;

}

Завдання № 18

Яке значення буде роздруковано в разі виконання наступної програми

#include <iostream.h>

main()

{

float x = 1, y = 2, real1 = 3, real2 =4 , real3 =5, real4 = 6;

real1 = x + y;

real2 = x - y;

real3 = x * y;

real4 = x / y;

cout << real1 << "\n";

cout << real2 << "\n";

cout << real3 << "\n";

cout << real4 << "\n";

cout << "\n\n";

return 0 ;

}

}

Завдання № 19

Яке значення буде роздруковано в разі виконання наступної програми

#include <iostream.h>

main()

{

int i, k=5;

i=10*(k++ );

cout << " i= " << i << " \n\n" ;

k--;

i = 10 * (++k);

cout << " i= " << i << " \n\n" ;

return 0;