₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,329,970 members, 8,443,235 topics. Date: Saturday, 11 July 2026 at 12:18 PM

Toggle theme

VickIdon's Posts

Nairaland ForumVickIdon's ProfileVickIdon's Posts

1 (of 1 pages)

ProgrammingRe: C Please Help by VickIdon(m): 9:51pm On Jan 30, 2012
Meanwhile, %4d means thus,
d is for decimal number. That means whatever is to be put as a substitute to %4d has to be an decimal integer. Not string nor char nor float.The % is used to state that a substitution is to be made. The 4 means that the integer to be printed has to be printed within a space of 4 digits. i.e, a number like (7) will be printed as ( 7), ignore brackets. 3 empty spaces. The fourth contains the number, which is 7. 27 wil be printed as ( 27), ignore brackets. Two empty spaces, 2 digits(2 and 7).
ProgrammingRe: C Please Help by VickIdon(m): 9:38pm On Jan 30, 2012
The code has some problems. Here are the corrections and what the code does,
1st Prob. Integer a is undeclared. Declare it b4 use.
2nd prob. Correct conver sion code (a-32)*5/9 , NOT (a-32)"5/9

Explanation. The first part of the printf code in quotes makes a substitution of the %4d with the values of a and (a-32)*5/9. That means the first %4d when printed will be replaced with D value of a, while the 2nd with that of (a-32)*5/9. The conversion (a-32)*5/9 is a standard math expression 4 converting temp in Farenheit to Degrees. a is the value in F, the expression gives the value in Degrees.

Let me know of any other problems.

1 (of 1 pages)