Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,161,449 members, 7,846,878 topics. Date: Saturday, 01 June 2024 at 05:26 AM |
Nairaland Forum / Science/Technology / Programming / Help! C++ (1960 Views)
Help: C Language And MPI ? (urgent Plz) / Female Programmer Here: Please Help (c Language) / Urgent! Plz Help - C Programming Problem (2) (3) (4)
Help! C++ by escobar07(m): 9:47pm On Mar 12, 2012 |
Write a program that inputs a five-digit integer, separates the integer into its individual digits and prints the digits separated from one another by spaces.(please use the integer and modulus operators). For example, 45678 should print: 4 5 6 7 8 9. Thanks. 1 Like |
Re: Help! C++ by escobar07(m): 12:37pm On Mar 13, 2012 |
Guys, pls help me out on this one na. cant believe i haven't the solution up till now. i know its not going to take more than 12 lines of codes, but mysteriously, i cant solve it. i'll be waiting sha. |
Re: Help! C++ by okeyxyz(m): 4:22pm On Mar 13, 2012 |
take the number in as input convert number to a string\array do a for() control statement to print each digit and space. finito!!! |
Re: Help! C++ by escobar07(m): 4:43pm On Mar 13, 2012 |
okeyxyz: take the number in as inputThanks, but am not even allowed to use arrays or strings, just |
Re: Help! C++ by okeyxyz(m): 1:06am On Mar 14, 2012 |
1 |
Re: Help! C++ by Kobojunkie: 3:02pm On Mar 14, 2012 |
@Poster, take the number, if you expect only 5 digit length all the time, then you consider the following Integer 45678/10000 = 4 and 45678 mod 10000 = 5678. Integer 5678/1000 = 5 and 5678 mod 1000 = 678. Integer 678/100 = 6 and 678 mod 100 = 78 Integer 78/10 = 7 and 78 mod 10 = 8. Now if you have variable length input digit, then you can, as someone suggested, using the String length function, figure out the length of the integer passed in, and then compute the power of 10 to work from. Kai!! I essentially did all the work for you. |
Re: Help! C++ by escobar07(m): 5:17pm On Mar 14, 2012 |
Kobojunkie: @Poster, take the number, if you expect only 5 digit length all the time, then you consider the followingGosh!Brilliant!.Only that you made me look silly.lol.Thanks anyway |
(1) (Reply)
Web Design Training Classes: 100% Practical Training / Need A Skilled Developer / Nigeria Mern Stack And Javascript Developers Thread
(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. 10 |