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]
3 years ago
9

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

Computers and Technology
1 answer:
Gelneren [198K]3 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
The practice of texting is most popular and what age group
Diano4ka-milaya [45]
Mostly teenagers and young adults (ages 14-21) text the most.
4 0
3 years ago
Read 2 more answers
Easy coding question, please help.
borishaifa [10]

Answers:

What is the index of the last element in the array? stArr1.length()-1

This prints the names in order. How would I print every other value? Change line 4 to: index = index +2

Change line 7 to: i < names.length

5 0
2 years ago
A new company starts up but does not have a lot of revenue for the first year. Installing anti-virus software for all the compan
Feliz [49]

WAN domain which stands for Wide Area Network and consists of the Internet and semi-private lines. The <span>RISKS are: Service provider can have a major network outage, Server can receive a DOS or DDOS attack</span> and A FTP server can allow anonymously uploaded illegal software.





7 0
3 years ago
Help me please. i need you help​
Fudgin [204]

Answer:

Can you provide the code

7 0
3 years ago
Photographs that are too dark or too light can be difficult to fix with photo-editing software.
Nana76 [90]
The answer is true :)
6 0
2 years ago
Read 2 more answers
Other questions:
  • What type of elements are bridges exposed to yearly
    13·2 answers
  • Encryption is the process of:
    12·1 answer
  • Nate wants to copy the style of his contact address to the normal template. Complete the paragraph to describe how he can access
    6·1 answer
  • A client contacted you to request your help in researching and supplying the hardware necessary to implement a SOHO solution at
    9·1 answer
  • How does the Rights Management Services feature help to protect information
    11·1 answer
  • Find the simple interest Jay owes on a five-year student loan of $48,000 with an annual interest rate of 5%.
    6·1 answer
  • According to the video, what kinds of projects would Computer Programmers be most likely to work on? Check all that apply.
    13·2 answers
  • Exercise#3: Write a program that performs the following: Declare a two arrays called arrayA and arrayB that holds integer and th
    14·2 answers
  • Assume you are given a boolean variable named isNegative and a 2-dimensional array of ints that has been created and assigned to
    8·1 answer
  • Why we need to interpret the drawing and plans
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!