Category Archives: C/C++ in UBUNTU

Run c/C++ propgram in Ubuntu

Standard

 

 

Install C and C++ Compilers in Ubuntu

  • sudo aptitude install build-essential¬†¬† /**** This will install all the required packages for C and C++ compilers ***/

Firstly compile the code using the following command

  • cc -c first.c

then create an executable using the following command

  • cc -o first first.c

Now run this executable using the following command

  • ./first

 

Compiling your first C++ program

If you want to run c++ program follow this procedure

g++ is the compiler that you must use.

you should use a .cpp file extension rather than a .c one

You need to create a file

  • sudo gedit “any filename”.cpp

 

Run your C++ Program using the following command

  • g++ first.cpp -o test
  • ./test

 

 

Advertisements