Help with C homework

Write a printf or scanf statement for each of the following:
a. Print unsigned integer 40000 left justified in a 15

Comments

  • : b. Read a hexadecimal value into a variable hex.

    scanf ("%x", &hex);

    : d. Print 100 in hexadecimal form preceded by 0x

    printf ("0x%x", 100);

  • Someone more kind than me answered first, yet your instructor might have wanted you to study the # flag and its use in the printf statement instead of the version shown for d. If your documentation isn't complete enough to show flags, you can see them at this reference:

    http://www.cplusplus.com/reference/clibrary/cstdio/printf.html

    You can also study the similarity of the scanf statement here:

    http://www.cplusplus.com/reference/clibrary/cstdio/scanf.html

    and note that the specifiers are the same, but as the previous responder showed, you need to remember to use & with your variable to correctly bring in the responce.

    Take Care,
    Ed
  • : a. Print unsigned integer 40000 left justified in a 15
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories