printf, align & field width?

From: DaveC (bobason456_at_hotmail.com)
Date: 06/09/04


Date: 9 Jun 2004 22:52:07 NZST

Hi.. I have a C exam in a few days.. Looking back at old exams I find a few
things we have not been taught / cant remember being taught. Below is a
question from last year.

My question is how do you align values and define field widths in the
printf function? I'm ok with the rest of the question.

Thanks
DaveC

(a) Declare a C structure that can contain data describing a computer.
The structure contains the following: the speed of the processor in GHz (a
floating point number), the amount of RAM in Mbytes (an integer), the size
of
the hard disk in Gbytes (an integer), the type of processor (a string) and
the
name of the manufacturer (a string). [2 marks]
(b) Declare a global variable of the above structure, and initialise it
with
reasonable values. (Do not use assignment statements.) [1 mark]
(c) Write C code for a function print_computer , that has a single argument
(a
pointer to a structure describing the computer).
The function prints the computer details on one line as follows:
The manufacturer left aligned in a field width of 30,
The processor type right aligned in a field width of 12,
The processor speed right aligned in a field width of 8 (1 decimal place),
The RAM size right aligned in a field width of 6,
The hard disk size right aligned in a field width of 6. [3 marks]



Relevant Pages

  • Re: Time to get an amateur radio licence
    ... As regards amateur radio, the best legacy most of us can hope to leave in recompense for the enjoyment we've had, is to encourage others to explore the hobby. ... The only thing that put me off the exam was the fact that I had a rampant interest in women and the fact that I could not pass the Morse test, as I could not get any help. ... Modern exam marks are shifted, according to how those sitting them achieve marks in the exam. ...
    (uk.radio.amateur)
  • Re: Another 10w M3
    ... ****Power out as opposed to power at the feed point avoids those little feeder loss -ahem- mistakes which lead to massive power outputs. ... in the exam result - not how the syllabus was taught. ... With the scheme now in force we have fewer making it to full than we had under the old scheme. ...
    (uk.radio.amateur)
  • Re: Usage of "older man"
    ... And I'm always impressed by people who can remember exam *questions* from their youth. ... I can tell the world exactly what I wrote in reply to "What do you think of Sir Robert Walpole?" ... Anxious not to miss any marks, I got off to a good start by writing "I think that Sir Robert Walpole ..." ... This heavy hint was useful for question 2 which began: "Draw a sketch map of EITHER Central Lowlands of Scotland OR Yorkshire OR Northumberland and Durham", and my answer didn't digress into the propriety of either...or...or. ...
    (alt.usage.english)
  • Re: A curse on all lecturers
    ... for the exams on your marks from your written assignments. ... Worked for me in A-level maths - had been working so hard on other stuff ... (further maths modules) ... Got a D in that particular exam, but still enough points overall for an A. ...
    (uk.rec.cars.modifications)