1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MakcuM [25]
3 years ago
12

12. Write C statement(s) that accomplish the following. a. Declare int variables x and y. Initialize x to 25 and y to 18. b. Dec

lare and initialize an int variable temp to 10 and a char variable ch to 'A'. c. Update the value of an int variable x by adding 5 to it. d. Declare and initialize a double variable payRate to 12.50. e. Copy the value of an int variable firstNum into an int variable tempNum. f. Swap the contents of the int variables x and y. (Declare additional variables, if necessary.) g. Suppose x and y are double variables. Output the contents of x, y, and the expression x 12 / y - 18. h. Declare a char variable grade and set the value of grade to 'A'. i. Declare int variables to store four integers. j. Copy the value of a double variable z to the nearest integer into an int variable x.
Computers and Technology
1 answer:
saul85 [17]3 years ago
3 0

Answer:

a.

int x = 25;

int y = 18;

b.

int temp = 10;

char ch ='a';

c.

x += 5;

d.

double payRate = 12.5;

e.

int tempNum = firstNum;

f.

int tempp = x;

x = y;

y = tempp;

g.

printf("Value of x = %f\n",x);

printf("Value of y = %f\n",y);

printf("Arithmetic = %f\n",(x + 12/y -18));

h.

char grade = 'A';

i.

int a,b,c,d;

a = 5; b = 2; c = 3; d = 6;

j.

int x = round(z);

Explanation:

The answers are straight forward.

However, I'll give a general hint in answering questions like this.

In C, variable declaration is done by:

data-type variable-name;

To declare and initialise the variable, you do;

data-type variable-name = value;

So, for questions that requires that we declare and initialise a variable, we make use of the above syntax..

Take (a) for instance:

int x = 25;

int y = 18;

Same syntax can be applied to (b), (d), (e), (h) & (I)

For question (c);

This can be done in two ways;

x = x + 5;

Or

x+=5;

Both will give the same result.

For question (f):

We start by initialise a temporary variable that stores x.

Then we store the value of x in y.

Then we store the content of the temporary variable to y.

This swaps the values of x and y

For question (g):

When printing a double variable in C, we make use of '\f' as a string format

For question (j):

The round function is used to round up a double variable to integer.

You might be interested in
Is a collection of limited versions of Microsoft office programs
alexgriva [62]
A Microsoft Office Suite.

 An office suite is a collection of Microsoft Office productivity software and is readily available for both Windows and Macintosh Operating System. A list of these programs includes, Microsoft Word, Excel, Access, Powerpoint, Publisher, and Outlook. Each of these programs serve a different purpose. 

3 0
3 years ago
What is the purpose of a report?
Tanzania [10]
C to organize data in a table
4 0
3 years ago
Consider the following method: public double doubleVal(double x) { return x *2; } The following code segment calls the method do
VashaNatasha [74]

Answer:

13.0

Explanation:

The method doubleVal() is created to accept a single parameter of type double.

It multiplies what ever the value of the parameter is and returns the resulting value.

In this question The method is called within this output statement System.out.println(doubleVal(val)); (Note that val had already been declared and assigned the value of 6.5)

The value 6.5 is doubled and outputed to the screen

8 0
3 years ago
True or False. A geosynchronous satellite changes its area in the sky each day.
nataly862011 [7]

Answer: False

Explanation: they remain in the same area

7 0
2 years ago
Read 2 more answers
Consider five wireless stations, A, B, C, D, and E.
klio [65]

Answer:

Check the explanation

Explanation:

A) Whenever C is sending to D, what other communications are possible?

C’s packet will be seen by A, B and D, but not by E. Thus, D can send to E at the sametime..

B) Whenever B is sending to A, what other communications are likely?

Even though B’s packet will not be seen by D, other nodes, e.g., E, or C, can’t send to D since the packets from these nodes will interfere with the packets from B at A. Therefore, other communications is not likely at the same time.

C) Whenever B is sending to C, what other communications are possible?

B’s packet will be seen by E, A and C, by not by D. therefore, E can send to D at the same point.

4 0
3 years ago
Other questions:
  • Write an expression that executes the loop body as long as the user enters a non-negative number.Note: If the submitted code has
    11·1 answer
  • Templates allow for the quick creation of _____.
    7·1 answer
  • A technician with a PC is using multiple applications while connected to the Internet. How is the PC able to keep track of the d
    8·2 answers
  • What is the value of variable num after the following code segment is executed?
    5·1 answer
  • You have to display or connect to network shares on remote computers. Which command-line utility will you use to accomplish the
    10·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    6·1 answer
  • A program uses two classes: dog and poodle. which class is the base class and which is the derived class?
    7·2 answers
  • Which is a common problem for inserting pictures into placeholders?
    10·1 answer
  • Questions Presscomion
    9·1 answer
  • 100 points, PLEASE HELP...To generate numbers between and including -10 to 10 you would use:
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!