0
0
Cprogramming~10 mins

Assignment operators in C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to assign the value 10 to variable x.

C
int x; x [1] 10;
Drag options to blanks, or click blank then click option'
A=
B==
C+=
D-=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '=' causes a comparison, not assignment.
Using '+=' or '-=' changes the value instead of assigning.
2fill in blank
medium

Complete the code to add 5 to variable y using an assignment operator.

C
int y = 10; y [1] 5;
Drag options to blanks, or click blank then click option'
A-=
B+=
C=
D*=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' will overwrite y instead of adding.
Using '-=' or '*=' will subtract or multiply instead of adding.
3fill in blank
hard

Fix the error in the code to multiply variable z by 3 using an assignment operator.

C
int z = 4; z [1] 3;
Drag options to blanks, or click blank then click option'
A-=
B+=
C*=
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' will overwrite z instead of multiplying.
Using '+=' or '-=' will add or subtract instead of multiplying.
4fill in blank
hard

Complete the code to subtract 2 from variable a using an assignment operator.

C
int a = 7; a [1] 2;
Drag options to blanks, or click blank then click option'
A-=
B+=
C=
D*=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' instead of '-=' changes the operation.
Using '*=' or '=' incorrectly.
5fill in blank
hard

Complete the code to divide variable b by 4 using an assignment operator.

C
int b = 20; b [1] 4;
Drag options to blanks, or click blank then click option'
A*=
B=
C;
D/=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*=' instead of '/=' changes the operation.
Using ';' in the blank causes a syntax error.