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]
4 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]4 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
Function of pons for class 7​
Dmitriy789 [7]
The pons is the primary structure of the brain stem present between the midbrain and medulla oblongata. It serves as a relay signals between the lower cerebellum, spinal cord, the midbrain, cerebrum and other higher parts of the brain. The main functions of the pons include: Controlling sleep cycles.
6 0
3 years ago
Alice is adding a chart in a spreadsheet. Which option will allow you her to give the chart a suitable title and subtitle?
Anon25 [30]

Chart elements is the answer.


8 0
3 years ago
Read 2 more answers
First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).
Nutka1998 [239]

Answer:

// name of the package

package stringlength;

// Scanner is imported but it is not needed

// So it is commented

// import java.util.Scanner;

// The class name StringLength is defined

public class StringLength {

// main method to signify the beginning of program execution

public static void main(String[] args) {

// if-statement to check if argument is supplied to

// command line

if(args.length > -1) {

// the first argument is read and assigned to input

String input = args[0];

int length = input.length(); // using length() method in String class

System.out.println("Your string has a length of "+length+" characters.");

} else {

System.out.println("Please enter your string argument in quote");

}

}

}

Explanation:

The code works fine with little modification and comments. The user should supply the string arguments in quote. The quote must surround the strings because our logic read the first argument passed to the command line. Inserting a string with space between them will provide a wrong output.

A sample image is attached.

6 0
3 years ago
I WILL GIVE BRAINLIEST TO WHO ANSWERS FIRIST AND CORRECT
forsale [732]

Answer:

Act like search engines

Explanation:

They will give you intel on about basically anything and they have their own opinion on it aswell‍♀️

4 0
3 years ago
Read 2 more answers
What is the point of having bullets points in a text box
Ludmilka [50]
You should have bullets in a text box in case you have a list of stuff. For example:

Computer Parts

.Tower

.Monitor

. Mouse

.Printer


3 0
4 years ago
Other questions:
  • Using javaFX components
    6·1 answer
  • A Hospital wants to store different types of data I need to find the best storage device for each type and why what is the best
    14·1 answer
  • If we assume the modern view of existential import, why is the following syllogism invalid? No computer is made of clay. All com
    15·1 answer
  • 10. Question<br> What are the drawbacks of purchasing something online? Check all that apply.
    5·1 answer
  • What If smart phones / computers didn't exist? <br>​
    5·1 answer
  • DEFINE TRANSLATORY MOTION.<br>​
    15·1 answer
  • 1. Assume that in an implementation of the RSA cryptosystem one modular squar- ing takes 75% of the time of a modular multiplica
    15·1 answer
  • You cannot then move and resize the control on the form as desired with your mouse TRUE OR FALSE​
    6·2 answers
  • Plz plz plz help me with me
    14·2 answers
  • Write a pseudocode algorithm to ask the user to input the name of a student, the marks he/she received in a test and the worth o
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!