floating point (invalid)

This is a discussion on floating point (invalid) within the C++ Programming forums, part of the General Programming Boards category; hey guys, i need help with this question. i need to write a program to get the output which is ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    1

    floating point (invalid)

    hey guys, i need help with this question.

    i need to write a program to get the output which is :

    i) there will be two class which is info_student and mark_student. class mark_student will be friend to a class info_student.

    ii) class info student will have name and ic with data type character as a variable. it also have function set_data that accept two variable above as a pointer in the parameter list.

    iii) while mark_student will have mark1, mark2 and total with data type float. the function is setmark, calculateMark and display.

    i already programmed and compiled the code, but i have the output show "floating point invalid" when i input the data. what have i done wrong here?


    Code:
    #include<iostream.h>
    class info_mark;
    class info_student
    {
    private:
    char name,ic;
    public:
    int student()
    {return name,ic;}
    };
    
    class info_mark
    {
    float mark1,mark2;
    public:
    int calculate_mark()
    {return mark1 +mark2;}
    };
    
    void main()
    {
    char a,b;
    float m,n;
    cout<<"Name:";
    cin>>a;
    cout<<"Ic:";
    cin>>b;
    
    cout<<"mark 1:";
    cin>>m;
    cout<<"mark 2:";
    cin>>n;
    
    cout<<"total:"<<m+n;
    }

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    You are not even using the classes?

    Exactly what do you enter? Your names can only be one character long!! If your input is incorrect, the variables will just contain garbage.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,655

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. checking for floating point number
    By ssharish2005 in forum C Programming
    Replies: 6
    Last Post: 10-18-2005, 09:14 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. Floating point #'s, why so much talk about it?
    By scuzzo84 in forum C Programming
    Replies: 5
    Last Post: 09-20-2005, 05:29 PM
  4. how do you check for a floating point vlaue in c??
    By xenodvs1 in forum C Programming
    Replies: 4
    Last Post: 02-12-2003, 06:52 AM
  5. Floating point exceptions
    By Boris in forum C++ Programming
    Replies: 8
    Last Post: 11-19-2001, 08:32 AM

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