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
Classroom content transaction <br> examples use of IT
padilas [110]

Answer:

1. Online classes

2. Presentation

3. Account of books

6 0
3 years ago
What are some characteristics of filtering junk email in Outlook 2016? Check all that apply.
tatiyna

Answer:

hold on i wrote this  in my engineeering class hold on

Explanation:

but just wait

3 0
3 years ago
Read 2 more answers
Select two netiquette guidelines. In three to five sentences, explain why these guidelines make professional online communicatio
meriva
Netiquette is etiquette when using the internet. The first guideline refers to posts on social media. Individuals should be mindful that posts can be read by anyone including employers and family members. Individuals need to ensure that material shared is not offensive. The next guideline refers to materials or content that is posted. Users must ensure that material posted does not belong to someone else or is copyrighted. Permission must be sought the owner must be cited or recognized. 
7 0
3 years ago
Read 2 more answers
In 1970, the federal government created __________ to both assist and require employers and employees to make the prevention of
Aleksandr-060686 [28]

OSHA

Occupational Safety Health Administration

4 0
3 years ago
The two key elements of any computer system are the____and the _____.
Virty [35]
Easy.
Hardware and software!
Did you ever try to use a computer with only mouse and monitor?
8 0
3 years ago
Other questions:
  • What car dealership websites did you use to conduct your research?​
    8·1 answer
  • Fill in the blank.
    7·1 answer
  • To create a new query in Design view, click CREATE on the ribbon to display the CREATE tab and then click the ____ button to cre
    9·1 answer
  • Sorting table rows is based on the data in the selected        A. cell range.   B. cell.   C. column.   D. row.
    12·2 answers
  • Consider the following threats to Web security, and describe how each is countered by a particular feature of SSL.
    15·1 answer
  • Why is it so important to have employees who can critically think?
    7·2 answers
  • One key feature of malware is that it:
    13·1 answer
  • Compare mini and mainframe computer in terms of speed,memory and storage​
    15·1 answer
  • How many 3 byte sequences contain at least five consecutive 0-bits
    7·1 answer
  • Describe a NIC card and can you have more than one?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!