It's UWAweek 51

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying selected article
Showing 1 of 1168 articles.
Currently no other people reading this forum.


 UWA week 33 (2nd semester, week 4) ↓
SVG not supported

Login to reply

👍?
helpful
12:04pm Tue 15th Aug, Christopher M.

ANONYMOUS wrote:
> I've noticed that both %d and %i have been used in labs and workshop solutions to print information stored in variables with 'int' datatype. I don't understand when to use which one. Is there a difference between them or can they be used interchangeably ?
When formatting output with printf() and friends, there really is no difference. However when scanning/parsing input with scanf() and friends, using "%i" supports reading in integers in different numeric bases, such as base-10 (decimal), base-8 (octal) and base-16 (hexadecimal). I prefer (try) to keep my use of "%i" consistent when using either printf() or scanf(), so try to always use "%i". And, while (I believe) "%d" is derived from the word 'decimal', my brain associates 'decimal' with 'decimal-point' and floating-point values, and not with a base-10 integer. So, again, I prefer "%i" with which I simply associate 'integer'.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy