how can i compile a program in c++ ?

Recommended Answers

All 5 Replies

You first have to have a C++ compiler. There are several free ones, including (but not limited to) Code::Blocks, and Visual Studio Express. Just google for them and you will find the download links. If you want Code::Blocks get the version with MinGW compiler. That is a popular compiler/IDE for beginners because it is easy to learn and portable between MS-Windows and *nix operating systems. If you are using *nix then Visual Studio is not available to you.

Just how you would do that would depend on the compiler, and possibly on the development environment you are using as well. Do you have a compiler chosen already, or are you looking to get one? If you have a compiler already, do you have an editor or Integrated Development Environment (IDE) in mind to use with it?

If not, have you looked into either Visual C++ Express (which comes with a built-in IDE called Visual Studio Express) or the Gnu Compiler Collection (which is mainly command-line driven, but can be used with IDEs such as Code::Blocks or Eclipse)?

Can you tell us something of what you are trying to do? By that I mean, are you compiling a specific program, or are you learning to program and need help getting started? The more you can tell us about what you need, the more specific we can be.

Thank you !
I am a begginer and i just want to see if it works to find greater no in Fibonacci string <M

# include <iostream>
# include <conio.h>
using namespace std ;
int main ()
{ int p=1 , i=1 , j=2 , M  ;
float =1/2 ; 
cout << “give M: “ ;
cin >> M  ;
for ( i=1 ; i<=M ; i++)
{ p=p*t ;
i=i+j ;
j=j+I ;
t=i/j ;
}
cout << “ Produkt is : “ << p ;
getch () ;
return 0 ;
}

Well, some of the headers included in this code are Windows ones, so you will need a Windows system and Windows compiler, such as (was suggested by the venerable Ancient Dragon) Visual Studio Express. One comment in line 15, you don't terminate or flush the line, and output to cout, just like stdout for C, won't flush to the display until either the output buffer is full, or there is some other event to cause it to flush. So, do this: cout << "Product is : " << p << flush;

OK, then. Well, as a beginner, I'd like to offer a quick lesson on the importance of suitable indentation:

#include <iostream>

using namespace std;

int main()
{
    int p = 1, i = 1, j = 2, M;
    float t = 1 / 2;

    cout << "give M: ";
    cin >> M;
    for (i = 1; i <= M; i++)
    {
        p *= t;
        i += j;
        j += i;
        t = i / j;
    }

    cout << "Produkt is: " << p ;

    return 0;
}

While this may look peculiar at first, you'll find that it is much more readable this way.

Now, then, did you pick one of the compilers I linked to, and were you able to try it? Or did you need more help?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.