Saturday 17 September 2011

C++ IN LINUX

Steps to install g++ compiler

  • Go to terminal (alt+ctrl+t or applications >accesories> terminal )
  •  write  sudo apt-get install g++ and then press enter 
 steps to work on g++ compiler 
  • go to desktop 
  • right click anywhere on empty space
  • select create document and then empty file 
  • name the file with extension example- rimpy.cpp
  • write the program you want to run 
  • save your program and then go to terminal 
  • type cd Desktop 
           g++ rimpy.cpp 
  • if your program is error free then a file name a.out will be created on the desktop which stores the output of your program, but there is any error in the program then it errors will be shown in terminal.
  • now go to terminal and give command 
               ./a.out 
then press enter your output will be seen in the terminal.
Example of g++ program 
#include<iostream>
using namespace std;
int main()
{
cout<<"hello world";
return 0;
}

No comments:

Post a Comment