# Write a character literal representing the (upper case) letter a.

1. Write a character literal representing the (upper case)letter A
.

2. Write a character literal representing acomma.
3. Write a character literal representing the digit 1 .
4. Declare a character variable named c.
5. Calculate the average (as a double) of the valuescontained
in the integer variables num1, num2, num3 and assign thataverage to
the double variable avg.
Assume the variables num1, num2, and num3
havebeen declared and assigned values, and the variable
avgdeclared.
6. Given two integer variables distance and speed , write an
expression that divides distance by speed using floating point
arithmetic, i.e. a fractionalresult should be produced.
7. Given an integer variable drivingAge that has alreadybeen
declared, write a statement that assigns the value 17 to drivingAge
.
8. Given two integer variables oldRecord and newRecord , write
a statement that gives newRecord thesame value that oldRecord
has.
9. Given two integer variables matricAge and gradAge , write a
statement that gives gradAge a valuethat is 4 more than the value
of matricAge.
10. Given an integer variable bridgePlayers , write astatement
that increases the value of that variable by 4.
11. Given an integer variable profits , write astatement that
increases the value of that variable by a factor of 10 .
12. Given two int variables, i and j , whichhave been declared
and initialized, and two other intvariables, itemp and jtemp ,
which have been declared,write some code that swaps the values in i
and j bycopying their values to itemp and jtemp respectively,and
then copying itemp and jtemp to j and irespectively.
13. Given three already declared int variables, i , j , and
temp , write some code that swaps thevalues in i and j . Use temp
to hold the value of i and then assign j 's value to i . The
originalvalue of i , which was saved in temp , can now beassigned
to j .
14. Given two int variables, firstPlaceWinnerand
secondPlaceWinner , write some code that swaps theirvalues. Declare

1. Write a character literal representing the (upper case)letter
A .

'A'

2. Write a character literal representing acomma.

','

3. Write a character literal representing the digit 1 .

'1'

4. Declare a character variable named c.

char c;

5. Calculate the average (as a double) of the valuescontained in
the integer variables num1, num2, num3 and assign thataverage to
the double variable avg.

Assume the variables num1, num2, and num3 havebeen
declared and assigned values, and the variable avgdeclared.

avg=(double)(num1+num2+num3) /3.0 ;

6. Given two integer variables distance and speed , write an
expression that divides distance by speed using floating point
arithmetic, i.e. a fractionalresult should be produced.

(float) distance /(float) speed;

7. Given an integer variable drivingAge that has alreadybeen
declared, write a statement that assigns the value 17 to drivingAge
.

drivingAge=17;

8. Given two integer variables oldRecord and newRecord , write a
statement that gives newRecord thesame value that oldRecord
has.

newRecord=oldRecord;

9. Given two integer variables matricAge and gradAge , write a
statement that gives gradAge a valuethat is 4 more than the value
of matricAge.

10. Given an integer variable bridgePlayers , write astatement
that increases the value of that variable by 4.

bridgePlayers=bridgePlayers+4;

11. Given an integer variable profits , write astatement that
increases the value of that variable by a factor of 10 .

profits=profits *10

12. Given two int variables, i and j , whichhave been declared
and initialized, and two other intvariables, itemp and jtemp ,
which have been declared,write some code that swaps the values in i
and j bycopying their values to itemp and jtemp respectively,and
then copying itemp and jtemp to j and irespectively.

itemp=i;

jtemp=j;

i=jtemp;

j=itemp;

13. Given three already declared int variables, i , j , and temp
, write some code that swaps thevalues in i and j . Use temp to
hold the value of i and then assign j 's value to i . The
originalvalue of i , which was saved in temp , can now beassigned
to j .

temp=i;

i=j;

j=temp;

14. Given two int variables, firstPlaceWinnerand
secondPlaceWinner , write some code that swaps theirvalues. Declare