Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,962 members, 7,817,830 topics. Date: Saturday, 04 May 2024 at 08:40 PM

C Please Help - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / C Please Help (1654 Views)

C Please Help (2) (3) (4)

(1) (Reply) (Go Down)

C Please Help by solesty(m): 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
black.rules:

Hi, pls how do I get the C++ compiler ?
I need it.
Thanks.

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)

Apple's IOS 9 And Nairaland Issues ..... / My Course Has Been Approved On Aqskill / "extended Mapi" Challenge For C++ Gurus

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.