A simple C++ program on dev c++

Discussion in 'Programming' started by sridhar_91, Feb 14, 2011.

  1. #1
    #include <iostream.h>
    int add(int a,int b, int c=3);
    main()

    {
    int x,y,z;
    x=add(10,20,30);
    y=add(40,50)
    z=add(10)
    cout<<x<<endl<<y<<"\n"<<z;
    }


    Tells me theres something wrong with the header file iostream.h . I dont understand it?
     
    sridhar_91, Feb 14, 2011 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What is the exact error message?

    Try #include <iostream>
    Are you trying to compile with gcc instead of g++?
     
    Cash Nebula, Feb 14, 2011 IP
  3. Bhavye Sankhla

    Bhavye Sankhla Member

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #3
    here's the program with rectified errors.
    its running in tcc successfully.
    contact me for further support.

    
    #include <iostream.h>
    int add(int a,int b, int c=3)
    { return a+b+c;}
    void main()
    
    {
    int x,y,z;
    const int k=10;
    x=add(10,20,30);
    y=add(40,50);
    z=add(10,k);
    cout<<x<<endl<<y<<"\n"<<z;
    }
    
    Code (markup):
    for dev c++ :

    
    #include<iostream.h>
    #include<conio.h>
    int add(int a,int b, int c=3)
    { return a+b+c;}
    int main()
    
    {
    int x,y,z;
    const int k=10;
    x=add(10,20,30);
    y=add(40,50);
    z=add(10,k);
    cout<<x<<endl<<y<<"\n"<<z;
    getch();
    return 0;
    }
    Code (markup):
     
    Last edited: Feb 15, 2011
    Bhavye Sankhla, Feb 15, 2011 IP
  4. freelancewebaz

    freelancewebaz Well-Known Member

    Messages:
    976
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    145
    #4
    Since when is .h included when using ISO CPP std lib headers?
     
    freelancewebaz, Feb 18, 2011 IP
  5. Bhavye Sankhla

    Bhavye Sankhla Member

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #5
    lol... its working program. i tested b4 posting.
     
    Bhavye Sankhla, Feb 18, 2011 IP
  6. Meenakshi

    Meenakshi Peon

    Messages:
    131
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    u haven't mention the value for a,b.
     
    Meenakshi, Feb 21, 2011 IP