| | n> hint and guide for lab 2.cpp | |
|
| Author | Message |
|---|
susastra
Number of posts: 11 Registration date: 2008-10-08
 | Subject: n> hint and guide for lab 2.cpp October 9th 2008, 19:26 | |
| you guys figure it out how to do ? im a bit blur here on how to print out the digits of the integer... i alrdy try to use the char data type, it can print out the digits. but how to swap, if it is char? blurblur... need hints and guides... |
|
 | |
citsoon
Number of posts: 41 Age: 22 Location: Woodlands Registration date: 2008-10-07
 | Subject: Re: n> hint and guide for lab 2.cpp October 9th 2008, 20:46 | |
| instead of storing it to char, u should try to convert it to int type, so that when doing swapping of digits, just use the formula that Dr Heng given, 1234 actually to display on screen, is 1*1000 + 2*100 + 3*10 + 4 ok, this should be enough, if i state too clearly, then it's become meaningless, try to figure out. |
|
 | |
xiaoming
Number of posts: 5 Age: 23 Registration date: 2008-10-07
 | Subject: Re: n> hint and guide for lab 2.cpp October 9th 2008, 20:54 | |
| Hi guys, Dr heng said we should declare tat the work is done ourselves. How do we go bout doing tat? input a \\Work is done by XiaoMing? or do a " cout" stating the work is done by me? |
|
 | |
susastra
Number of posts: 11 Registration date: 2008-10-08
 | Subject: Re: n> hint and guide for lab 2.cpp October 9th 2008, 21:03 | |
| well, the question did mention that n = 1234 is 1 integer. so if 1234 is 1 integer, how to print it digit by digit ? o_o still blur here.. |
|
 | |
donysukardi Admin

Number of posts: 54 Age: 19 Location: Holland Drive Registration date: 2008-10-05
 | Subject: Re: n> hint and guide for lab 2.cpp October 9th 2008, 21:13 | |
| | xiaoming wrote: | | Hi guys, Dr heng said we should declare tat the work is done ourselves. How do we go bout doing tat? input a \\Work is done by XiaoMing? or do a "cout" stating the work is done by me? |
Just use the comment //blah blah blah
The hint is it has something to do with modulus %, try to figure it out.. |
|
 | |
citsoon
Number of posts: 41 Age: 22 Location: Woodlands Registration date: 2008-10-07
 | Subject: Re: n> hint and guide for lab 2.cpp October 9th 2008, 21:16 | |
| | susastra wrote: | well, the question did mention that n = 1234 is 1 integer. so if 1234 is 1 integer, how to print it digit by digit ? o_o still blur here.. |
ok, further hint, using multiplication we can obtain a 4 digits number, so using other type we can obtain the digits seperately. |
|
 | |
susastra
Number of posts: 11 Registration date: 2008-10-08
 | Subject: Re: n> hint and guide for lab 2.cpp October 9th 2008, 22:31 | |
| at last i got the answer -_-;;; thx all for helping.. |
|
 | |
citsoon
Number of posts: 41 Age: 22 Location: Woodlands Registration date: 2008-10-07
 | Subject: Re: n> hint and guide for lab 2.cpp October 10th 2008, 06:41 | |
| hope that i did help a bit.... |
|
 | |
kevin
Number of posts: 4 Registration date: 2008-10-11
 | Subject: Re: n> hint and guide for lab 2.cpp October 11th 2008, 09:30 | |
| hmmm...i'm still thinking of how to actually swap the numbers |
|
 | |
citsoon
Number of posts: 41 Age: 22 Location: Woodlands Registration date: 2008-10-07
 | Subject: Re: n> hint and guide for lab 2.cpp October 12th 2008, 23:14 | |
| we learnt that in CSCI103, didn't we?? last few pages... |
|
 | |
| | n> hint and guide for lab 2.cpp | |
|