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
Tasya [4]
2 years ago
9

Write a program to test the difference between %d and %i conversion

Computers and Technology
1 answer:
Gelneren [198K]2 years ago
7 0
Void test(char *s)
{
  int i, d;
  sscanf(s, "%i", &i);
  printf("%s converts to %i using %%i\n", s, i);
  sscanf(s, "%d", &d);
  printf("%s converts to %d using %%d\n", s, d);
}

int main()
{
  test("123");
  test("0x123");
  return 0;
}

outputs:
123 converts to 123 using %i
123 converts to 123 using %d
0x123 converts to 291 using %i
0x123 converts to 0 using %d

As you can see, %i is capable of parsing hexadecimal, whereas %d is not. For printf they're the same.
You might be interested in
computer has a 32-bit instruction word broken into fields as follows: opcode, six bits; two register file address fields, five b
lina2011 [118]

Answer:

a.  2^6, or 64 opcodes.

b.  2^5, or 32 registers.

c. 2^16, or 0 to 65536.

d.  -32768 to 32768.

Explanation:

a. Following that the opcode is 6 bits, it is generally known that the maximum number of opcodes should be 2^6, or 64 opcodes.

b. Now, since the size of the register field is 5 bits, we know that 2^5 registers can be accessed, or 32 registers.

c. Unsigned immediate operand applies to the plus/minus sign of the number. Since unsigned numbers are always positive, the range is from 0 to 2^16, or 0 to 65536.

d. Considering that the signed operands can be negative, they need a 16'th bit for the sign and 15 bits for the number. This means there are 2 * (2^15) numbers, or 2^16. However, the numbers range from -32768 to 32768.

6 0
3 years ago
Use the arr field and mystery () method below.
kolezko [41]

Answer:

The sum of all positive even values in arr

Explanation:

We have an array named arr holding int values

Inside the method mystery:

Two variables s1 and s2 are initialized as 0

A for loop is created iterating through the arr array. Inside the loop:

num is set to the ith position of the arr (num will hold the each value in arr)

Then, we have an if statement that checks if num is greater than 0 (if it is positive number) and if num mod 2 is equal to 0 (if it is an even number). If these conditions are satisfied, num will be added to the s1 (cumulative sum). If num is less than 0 (if it is a negative number), num will be added to the s2 (cumulative sum).

When the loop is done, the value of s1 and s2 is printed.

As you can see, s1 holds the sum of positive even values in the arr

7 0
2 years ago
7. Explain the steps for formatting a shape ?
alisha [4.7K]

Answer:

To begin, select the shapes you want to format. To select more than one, press and hold the Shift key. When you select one or more shapes, a new Drawing Tools tab appears. Here, you can select Shape Fill to fill the selected shapes with a solid color, gradient, texture, or picture.

Explanation:

3 0
2 years ago
In what situations other than developing software might the process of analysis, design, development, test, deployment, and main
forsale [732]

In Systems development  or  traditional waterfall approach will the process of analysis, design, development, test, deployment, and maintenance be a useful approach.

<h3>What is software development?</h3>

Software development is known to be a term that connote the composition  of computer science works made for the process of developing , designing, and aiding software.

Note that In Systems development  or  traditional waterfall approach will the process of analysis, design, development, test, deployment, and maintenance be a useful approach. as it also uses the dteps listed above.

Learn more about software from

brainly.com/question/1538272

#SPJ1

7 0
2 years ago
A person who breaks into a computer, network, or online site is called
dybincka [34]

Answer:

B: Hacker

Explanation:

literally anything else aren't even real things besides hacker.

5 0
2 years ago
Read 2 more answers
Other questions:
  • A subclass of Value, LargerValue, is defined with a getValue method that returns twice the value of the parent. Which line is th
    13·1 answer
  • What happens as the key length increases in an encryption application?
    8·1 answer
  • Test if a number grade is an A (greater than or equal to 90). If so, print "Great!". Sample Run Enter a Number: 98 Sample Output
    7·1 answer
  • 1. Which of the following statements are true about routers and routing on the Internet. Choose two answers. A. Protocols ensure
    9·2 answers
  • What can be designed to create annoying glitches or destroy data
    11·1 answer
  • Which devices are used in networking
    15·1 answer
  • What is the correct order for writing the 3 dimensions for a 3D object? Here are the 3 dimensions:
    15·1 answer
  • Keira is creating an app for her cross-country team. Users will input their race times and the output will be a graph showing th
    6·1 answer
  • What is Japanese tradition?
    8·2 answers
  • What is the full form of RPM in computer ​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!