C++ software for home work

This is a discussion on C++ software for home work within the C++ Programming forums, part of the General Programming Boards category; HI GUys, As part of my electronics course, we are doing a brief course on programming, but i have been ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    4

    C++ software for home work

    HI GUys,

    As part of my electronics course, we are doing a brief course on programming, but i have been unable to attend my college due to the lifts being down (wheels for legs)

    and now i am far behind,
    and i was wondering if theirs a free program that i could use to make such easy programs as below,

    thanks

    Code:
    #include<iostream.h>
    
    void main(void)
    {
    int voltage,resistance,current;
    
    cout<<"enter current(amps):\t"<<endl;
    cin>>current;
    
    cout<<"enter resistance(ohms):\t"<<endl;
    cin>>resistance;
    
    
    voltage=current*resistance;
    
    cout<<"current:\t"<<current<<endl;
    cout<<"resistance:\t"<<resistance<<endl;
    
    cout<<"voltage:\t"<<voltage<<endl;
    }

  2. #2
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    it's generally called a brain and everyone comes equipped with one (though quality control isn't the best with the result that there's a large spread in capabilities between units installed, we apologise for the inconvenience).

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    do you mean a compiler?

  4. #4
    Banned Yuri's Avatar
    Join Date
    Aug 2005
    Location
    Breukelen, The Netherlands
    Posts
    133
    Code:
    void main(void)
    . You better should use:
    Code:
    int main()
    If you mean a compiler I would advice you to use Dev-C++, I use it too.

  5. #5
    Registered User
    Join Date
    Feb 2006
    Posts
    4
    it's generally called a brain and everyone comes equipped with one (though quality control isn't the best with the result that there's a large spread in capabilities between units installed, we apologise for the inconvenience).
    yeh thanks

    do you mean a compiler?
    sorry, yes, in college we use microsoft c++ 6.0, is there anything like this that i can use thats free, where you write the program like above, and then you can actually run it?

  6. #6
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094

  7. #7
    Registered User
    Join Date
    Feb 2006
    Posts
    4
    ive tried visual basics c++ 2005, but when ever i build somthing i get

    Cannot open include file: 'iostream.h': No such file or directory

  8. #8
    Registered User
    Join Date
    Feb 2006
    Posts
    4
    ok, ive just run this program in dev C++, it works on microsft visual C++ 6.0, but not on dev


    its asks for the current and then the resistance, but then just closes

    Code:
    #include<iostream.h>
    
    int main()
    {
    int voltage,resistance,current;
    
    cout<<"enter current(amps):\t"<<endl;
    cin>>current;
    
    cout<<"enter resistance(ohms):\t"<<endl;
    cin>>resistance;
    
    voltage=current*resistance;
    
    cout<<"current:\t"<<current<<endl;
    cout<<"resistance:\t"<<resistance<<endl;
    
    cout<<"voltage:\t"<<voltage<<endl;
    }

  9. #9
    Registered User
    Join Date
    Aug 2003
    Posts
    1,205
    That is because there is no iostream.h in the C++ standard, the standard states that the filename is iostream (note, no ".h").

    Same goes with fstream, no C++ standard header has .h as extension. Now the problem comes with files that come from C (stdio.h is such a file, basicly that is iostream's equivalent), with those files you take away the .h and add a c to the front, so the C-header stdio.h would be cstdio in C++.

    You should also read up on namespaces, but since the book/website/paper you have on C++ seems old and nonstandard i recommend you to go to http://www.cprogramming.com/tutorial.html and use those tutorials instead.

    Edit: To answer you latest question: That is because VC++ adds a functionality so that when you run the program through their IDE they will add a pause at end functionality automaticly (this is not added in the actual exe file, only when you run it through the IDE).

    To fix this in DevC++ and other compilers you can simply add a "cin.get()" before you call the return 0; in main. One note though, you should make a call to cin.ignore(); after you have done anything with cin, such as cin >> somevar;

    Ill give some example code for ya:
    Code:
    // This will not pause
    int main()
    {
      return 0;
    }
    
    
    // This will not pause
    #include <iostream>
    using std::cin;
    
    int main()
    {
      int someVar;
      cin >> someVar;
      cin.get();
      return 0;
    }
    
    
    // This will pause:
    #include <iostream>
    using std::cin;
    
    int main()
    {
      int someVar;
      int someOtherVar;
    
      cin >> someVar;
      cin.ignore();
      cin >> someOtherVar;
      cin.ignore();
    
      cin.get();
      return 0;
    }
    Last edited by Shakti; 02-14-2006 at 01:13 PM.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  10. #10
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	int voltage,resistance,current;
    
    	cout<<"enter current(amps):\t"<<endl;
    	cin>>current;
    
    	cout<<"enter resistance(ohms):\t"<<endl;
    	cin>>resistance;
    
    	voltage=current*resistance;
    
    //put the following in one command and used \n so that the program is a tad more efficient :D
    	cout<<"current:\t"<<current
                   <<"\nresistance:\t"<<resistance
                   <<"\nvoltage:\t"<<voltage<<endl;
    	
    	cin.ignore(); //incase there is something in the input stream, this clears it so that cin.get(); can work properly
    	cin.get(); //so that the program will pause before exiting
    	
    	return 0; //always return 0 if the program runs successfully
    }
    Doctored it up for you.

  11. #11
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    was under the impression you wanted something to write the sourcecode for you... That's what you asked after all, a program to write easy programs

  12. #12
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    If their was a program to make programs, programmers would be out a job ^,^. Programmings really not to complex - think of it as an attempt to create a second sun. .
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  13. #13
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    if you believe the marketing hype around architecture tools you'd think all those pesky programmers were already an unnecessary luxury for companies and all you need is some analyst to draw some UML diagrams and your entire application is ready at the push of a button.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Software Developer Opportunity in Delaware
    By Jdorazio in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 04-28-2009, 10:58 AM
  2. Replies: 3
    Last Post: 11-17-2008, 11:36 AM
  3. Writing a .gif animator software
    By rEtard in forum Windows Programming
    Replies: 5
    Last Post: 09-21-2005, 12:23 PM
  4. Is Linux More Secure Than Windows?
    By xErath in forum A Brief History of Cprogramming.com
    Replies: 69
    Last Post: 06-29-2005, 07:13 PM

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