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
How to charge your phone quickly
stepladder [879]
I found out that putting your phone on airplane mode will charge it faster
4 0
3 years ago
Read 2 more answers
In Microsoft Word, spelling errors are identified by a _____.
kvasek [131]
Red underline. Hope this helps.
5 0
2 years ago
Read 2 more answers
What is the diffrence between the the grassland and the savanna biomes
sergey [27]

Answer:

The term "savanna" is often used to refer to open grassland with some tree cover, while "grassland" refers to a grassy ecosystem with little or no tree cover.

Explanation:

5 0
3 years ago
Read 2 more answers
An alternative to hexadecimal notation for representing bit patterns is dotted decimal notation in which each byte
zysi [14]

An alternative to hexadecimal notation for representing bit patterns is dotted decimal notation in which each byte in the pattern is represented by its base ten equivalent. In turn, these byte representations are separated by periods. For example, 12.5 represents the pattern 0000110000000101 (the byte00001100 is represented by 12, and 00000101 is represented by 5), and the pattern 100010000001000000000111 is represented by 136.16.7. Represent each of the following bit patterns in dotted decimal notation,

a. 0000111100001111 b. 001100110000000010000000c. 0000101010100000

4 0
2 years ago
QUICK PLZZZZZZZ Which one of the following is considered a peripheral? A Software B Mouse C USB connector D Motherboard
il63 [147K]

A MOUSE is considered a peripheral. A peripheral device connects to a computer system to add functionality.

6 0
3 years ago
Other questions:
  • This program will output a right triangle based on user specified height triangle_height and symbol triangle_char. (1) The given
    9·1 answer
  • When using the “reply all” option, your message will automatically be sent to ____ recipients of the original message. ​?
    7·2 answers
  • A(n) _______ created in Microsoft Word or another word-processing program works well as a shell for a PowerPoint presentation.a.
    9·1 answer
  • Which of these statements best describes an application programming interface?
    5·1 answer
  • Fill in the blank
    11·1 answer
  • Explain what occurs when you synchronize computer and mobile devices.
    5·1 answer
  • You have been using the same computer for several years. To extend its service life, you decide to upgrade the processor. You ch
    13·1 answer
  • Along a road lies a odd number of stones placed at intervals of 10 metres. These stones have to be assembled around the middle s
    12·1 answer
  • Now that you have explored several different languages (Python, HTML, CSS, and JavaScript), what can you do to keep straight whi
    7·1 answer
  • What feature preserves your open apps and data, but allows another user to log in to his or her own session of the same computer
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!