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
Compound conditions require a computer to sense whether multiple conditions are true or false.
Anna71 [15]

Answer:

False

Explanation:

You can have multiple conditions in your while and for loops as well as your if statements.

4 0
3 years ago
Is nanotechnology is good or bad? and why?
LenKa [72]

Answer:

Nanoparticles do hold out much environmental promise. The same reactivity that makes them harmful in the body also means they can break down dangerous chemicals in toxic waste – or anywhere, for that matter. And their use in electronics drastically reduces power demand, which could cut greenhouse gases.

6 0
2 years ago
Read 2 more answers
In 1–2 sentences describe the purpose of comparison operators and give an example.
love history [14]
Comparison operators are used to compare between objects!
are they equal?  is one greater than the other?

if (a == b) ++a;
if (a > b) a = b;

for example when we use a sort function, comparison operators are used inside the function.

7 0
3 years ago
What types of activities are ideal for a robot to perform?
LUCKY_DIMON [66]

The type of activities that are ideal for a robot to perform are; Repetitive tasks

Robots are machines that are programmable by a computer which have the capacity of automatically carrying out a complex series of actions.

Now, robots are used in a wide array of industries which include manufacturing, assembly and packaging, transport, earth and space exploration, e.t.c.

The most common use are found primarily in the automobile industry where they are used to carry out repetitive tasks and those that are difficult or hazardous for humans.

Read more about robots at; brainly.com/question/9145476

3 0
3 years ago
Which best explains why the world first civilizations developed in river valley's
fiasKO [112]
They need to be close to a body of water and being in a valley is good because they are protected because they have mountains around
4 0
3 years ago
Other questions:
  • Andy designed a web page for a product-oriented industry using CSS properties. He used several HTML tags to create the web page.
    6·1 answer
  • You created a vm and installed windows server 2008 r2 over the network, using pxe boot. when you start the vm, it doesn't attemp
    7·1 answer
  • One in five teens have been tricked by someone online:
    14·2 answers
  • George has to develop a website for his dad’s cycle shop. He wants to focus mainly on the products and wants the website to have
    10·1 answer
  • What variation of a dictionary attack involves a dictionary attack combined with a brute force attack, and will slightly alter d
    8·2 answers
  • .
    8·1 answer
  • In powerpoint a point is _____ of an inch in height.
    6·1 answer
  • If an additional term relates to payment, quality, quantity, price, time, and place of delivery, the CISG considers the added te
    12·1 answer
  • why does my Minecraft screen this "play and "settings" instead of the regular layout with singleplayer, multiplayer, and options
    11·2 answers
  • Who prime minister of india​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!