DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 33

Thread: Finding a decimal

  1. #16
    Join Date
    Aug 2005
    Location
    Melbourne...Australia
    Posts
    279
    Quote Originally Posted by Nathan87
    durr woops
    You dont make any sense mate..

  2. #17
    Join Date
    Feb 2006
    Posts
    25
    Quote Originally Posted by Code_Nerd
    Code:
    void main()
    ***??? Very bad.. :(

    Nathan, how does your function testnum() know the value of s?

    You dont send it there in any way?

    all variables are assumed global as in orig code submitted by bubbster.

  3. #18
    Join Date
    Aug 2005
    Location
    Melbourne...Australia
    Posts
    279
    void main(), Global variables.. what next?? <iostream.h>..

    Not a prob Nathan.. I dont actually get what the OP is trying to do..

  4. #19
    Join Date
    Feb 2006
    Posts
    25
    if i understand correctly he just wants to show all the factors of a user supplied number (i.e. all numbers that divide evenly in to that number)

  5. #20
    Join Date
    Aug 2005
    Location
    Melbourne...Australia
    Posts
    279
    Quote Originally Posted by Nathan87
    variables s and u are global as in the original code submitted by bubbster

    Yes they are..

    I have no idea why he would do that? :eek: :eek:

  6. #21
    Join Date
    Feb 2006
    Posts
    25
    Quote Originally Posted by Code_Nerd
    Yes they are..

    I have no idea why he would do that? :eek: :eek:
    yes, not good practice but I just thought I would leave things the way they were as much as possible.
    Last edited by Nathan87; 02-02-2006 at 02:43 AM. Reason: typo

  7. #22
    Join Date
    Feb 2006
    Posts
    25
    better variable names wouldn't hurt either...

  8. #23
    Join Date
    Aug 2005
    Location
    Melbourne...Australia
    Posts
    279
    Quote Originally Posted by Nathan87
    if i understand correctly he just wants to show all the factors of a user supplied number (i.e. all numbers that divide evenly in to that number)
    Is that all?

    So if you enter 20 the answer is 1, 2, 4, 5, 10..

  9. #24
    Join Date
    Aug 2005
    Location
    Melbourne...Australia
    Posts
    279
    Quote Originally Posted by Nathan87
    if i understand correctly he just wants to show all the factors of a user supplied number (i.e. all numbers that divide evenly in to that number)
    If thats all they want..

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	int x = 200;
    	for(int y = 1; y <= x ; y++)
    	{
    		if((x % y) == 0)
    			cout<<y<<" ";
    	}
    	return 0;
    }

  10. #25
    Join Date
    Feb 2006
    Posts
    25
    Quote Originally Posted by Code_Nerd
    Is that all?

    So if you enter 20 the answer is 1, 2, 4, 5, 10..
    and 20.

  11. #26
    Join Date
    Feb 2006
    Posts
    25
    that would work, except the number to find the factors of must be accepted from the user, it can't be hard-coded.

  12. #27
    Join Date
    Aug 2005
    Location
    Melbourne...Australia
    Posts
    279
    Quote Originally Posted by Nathan87
    that would work, except the number to find the factors of must be accepted from the user, it can't be hard-coded.
    Of course..
    If the OP cant add that, they really shouldnt be here..

  13. #28
    Join Date
    Jan 2006
    Posts
    6
    Quote Originally Posted by Code_Nerd

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	int x = 200;
    	for(int y = 1; y <= x ; y++)
    	{
    		if((x % y) == 0)
    			cout<<y<<" ";
    	}
    	return 0;
    }
    See....I knew there was an easier way to do it. It works, except I just modded it with a cin for x. Thanks a bunch, but, I still want to get my code working.

  14. #29
    Join Date
    Aug 2005
    Location
    Melbourne...Australia
    Posts
    279
    No worries mate..

    If you would just explain what your after better, we would get there in under 2 pages ;)

  15. #30
    Join Date
    Nov 2003
    Posts
    4,118
    so this long winded thread was all about a cin>>x instead of int x=200; ?
    oh dear...
    Danny Kalev

Similar Threads

  1. Replies: 2
    Last Post: 09-27-2006, 07:29 PM
  2. c# - Decimal conversion
    By cema in forum .NET
    Replies: 2
    Last Post: 01-18-2006, 09:00 PM
  3. Conversion of decimal in Oracle to Access 2000
    By Villy Olsson in forum Database
    Replies: 4
    Last Post: 04-06-2002, 09:01 PM
  4. Replies: 2
    Last Post: 09-26-2001, 06:08 PM
  5. Textbox for Decimal Number
    By Dante in forum VB Classic
    Replies: 2
    Last Post: 06-23-2000, 02:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center