Thread: a simple noobs question

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    27

    a simple noobs question

    is there any way to declare a variable only storing positive numbers?

  2. #2
    Registered User
    Join Date
    Mar 2005
    Posts
    27
    please reply need some help

  3. #3
    Lost In Rain
    Join Date
    Mar 2005
    Location
    Someone's heart!
    Posts
    4
    use unsigned integer....while we declare a integer like int a..by default its signed(-128~127) but if its unsigned (0~255) it will take only positive values

    declaration:

    unsigned int u;

    But it will be integer....I dont know if you can use it in float type variables!

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    we declare a integer like int a..by default its signed(-128~127) but if its unsigned (0~255)
    that would be a char
    an int would be
    unsigned int 0 to 65,535
    int -32,768 to 32,767





    (my 666th post...... )
    Last edited by sand_man; 03-30-2005 at 07:15 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 08:10 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  4. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM