Book of tasks on programming. Old version

 

 by Aliaksandr N. Prykhodzka

 

visual, database, частота, pascal, record, procedure, ссылка, asm, семестр, константа, until, реализация, array, самообучение, обучение, tree, manuel de programmation
 

for valuable work you must have JavaScript (allow active content)

Java. J.16. Nest of tasks. Tasks on substitution of conditions

 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.16.1     Answer      Pascal-analogue      Visual Basic-analogue

Put conditions into empty places to force the program will produce the number 30.


int AA()
{
    int k1=0;    int k2=0;
    while (______)
    {
        k2+=1;
        k1=k1+k2;
    }
    k1=k1+2;
    return k1;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.16.2     Answer      Pascal-analogue      Visual Basic-analogue

Put conditions into empty places to force the program will produce the number 30.


int AA()
{
    int k1=0;    int k2=0;
    while (k2<2)
    {
        k2+=1;
        while (_________) k1+=1;
    }
    k1=k1+5;
    return k1;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.16.3     Answer      Pascal-analogue      Visual Basic-analogue

Put conditions into empty places to force the program will produce the number 30.


int AA()
{
    int k1=0;
    for (int k2=1; k2<11; k2++)
        if (__________) k1=k1+k2;
    return k1;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.16.4     Answer      Pascal-analogue      Visual Basic-analogue

Put conditions into empty places to force the program will produce the number 30.


int AA()
{
    int k1=1;
    for (int k2=1; k2<6; k2++)
        if (________) k1=k1*k2;
    return k1;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.16.5     Answer      Pascal-analogue      Visual Basic-analogue

Put conditions into empty places to force the program will produce the number 30.


int AA()
{
    int k1=1;
    for (int k2=1; k2<11; k2++)
        if (________) k1=k1*k2;
    return k1;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.16.6     Answer      Pascal-analogue      Visual Basic-analogue

Put conditions into empty places to force the program will produce the number 30.


int AA()
{
    int k1=10;    int k2=10;    int k3=10;
    while (______) k1=k1 / 2;
    while (______) k2=k2 / 3;
    while (______) k3=k3 / 5;
    k1=k1*k2*k3;
    return k1;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.16.7     Answer      Pascal-analogue      Visual Basic-analogue

Put conditions into empty places to force the program will produce the number 30.


int AA()
{
    boolean pr=true;
    int k1=0;    int k2=0;
    while (pr)
    {
        k1=k1+2;
        k2=k2+3;
        pr= ______ ;
    }
    k1=(k1*k2) / (k1+k2);
    return k1;
}


 

 

Calculator

/ - division

\ - rest

S - sum of numbers from and to

P - multiply numbers from and to

J.16.8     Answer      Pascal-analogue      Visual Basic-analogue

Put conditions into empty places to force the program will produce the number 30.


int AA()
{
    int k1=1;
    for (int k2=1; k2<4; k2++)
    while (________) k1=k1+k2;
    return k1;
}


 

©   Aliaksandr Prykhodzka    1993 - 2007