₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,329,953 members, 8,443,150 topics. Date: Saturday, 11 July 2026 at 09:49 AM

Toggle theme

C Please Help - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingC Please Help (1736 Views)

1 Reply (Go Down)

C Please Help by solesty(op): 5:17pm On Jan 07, 2012
Please explain this to me especially the line of printf ( Conversion to celsius) #include <stdio.h> int main() { a=0 while (a<=100) { printf("%4d degrees F=%4d degrees C\n", a,(a-32)"5/9), a = a+10 } return 0, }
Re: 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.
Re: C Please Help by Mobinga: 9:43pm On Jan 30, 2012
cool
Re: 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).
Re: C Please Help by blackrules1(m): 7:45am On Feb 02, 2012
Hi, pls how do I get the C++ compiler ?
I need it.
Thanks.
Re: C Please Help by SNCOQ3(m): 4:29pm On Feb 05, 2012
VickIdon:
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).
Sorry but the bolded is incorrect. d is integer, f (floating-point) is for decimal. Using %d where %f is appropiate like in this case will truncate the fractions to an integer. e.g 32.231 becomes 32
Re: C Please Help by SNCOQ3(m): 4:36pm On Feb 05, 2012
[quote author=black.rules link=topic=841152.msg10101889#msg10101889 date=1328165104]Hi, pls how do I get the C++ compiler ?
I need it.
Thanks.[/quote]go for GNU Compiler collection(gcc). its the world most popular open-source solution.
http://gcc.gnu.org/
Re: C Please Help by ektbear: 11:35pm On Feb 05, 2012
see me c wahala
1 Reply

C Please Help234

Any Unity3D Developer Here?When And Why To Study Computer ScienceI Created A Directory Site For Nigeria Famous Websites, Need Advice.