SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Tony Gaddis
Chapter:
Repetition Structures
Exercise:
Algorithm Workbench
Question:6 | ISBN:9780132576376 | Edition: 2

Question

Rewrite the following statements using augmented assignment operators.
a. x = x + 1
b. x = x * 2
c. x = x / 10
d. x = x - 100

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

a)

Given statement: x = x + 1

The augmented assignment is used for the sake of writing short code statements.
The augmented assignment operators of  x = x + 1 is x +=1

b)

Given statement: x = x * 2
The augmented assignment is used for the sake of writing short code statement.
The augmented assignment operators of x = x * 2 is x*=2

c)

Given statement: x = x/10
The augmented assignment is used for the sake of writing short code statement.
The augmented assignment operators of  x = x/10 is  x/=10

d)

Given statement: x = x -100
The augmented assignment is used for the sake of writing short code statement.
The augmented assignment operators of  x = x -100 is x-=100

 

0 0

Discussions

Post the discussion to improve the above solution.