some questions about data types

This is a discussion on some questions about data types within the C++ Programming forums, part of the General Programming Boards category; Hi I have a question , do we use data types eg "float", "int" and "double" only when we do ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    some questions about data types

    Hi

    I have a question , do we use data types eg "float", "int" and "double"

    only when we do arithmatic operation or we can even use them when we want to specify simply age,bus number and etc in a program?

  2. #2
    Registered User fdrake's Avatar
    Join Date
    Dec 2011
    Posts
    6
    Quote Originally Posted by student111 View Post
    Hi

    I have a question , do we use data types eg "float", "int" and "double"

    only when we do arithmatic operation or we can even use them when we want to specify simply age,bus number and etc in a program?
    it depends from the contents ... ex if you need to calculate the average age of a group of ppl you may use float . If you need to find out the tot number of ppl relate to different ages int it's enough.. it all depends how you use your data

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    5,832
    No.

    Generally speaking, one would expect to be able to do arithmetic operations on a user-defined UnboundedInteger type.
    Right 98% of the time, and don't care about the other 3%.

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,261
    You use whatever makes sense according to what data you need to store or manipulate.

    Perhaps you'd be better off asking about a particular scenario rather than something general.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. data types
    By britto116 in forum C Programming
    Replies: 12
    Last Post: 11-13-2009, 06:32 AM
  2. Data Types
    By kas2002 in forum C Programming
    Replies: 1
    Last Post: 05-21-2009, 07:30 AM
  3. what are the data types?
    By Milhas in forum C Programming
    Replies: 3
    Last Post: 03-26-2008, 08:31 AM
  4. data types types...
    By gftmc in forum C++ Programming
    Replies: 3
    Last Post: 09-11-2006, 11:30 AM
  5. data types
    By 182 in forum C++ Programming
    Replies: 10
    Last Post: 02-18-2006, 04:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21