How to run a C++ program in Ubuntu (Linux)

How to run a C++ program in Ubuntu (Linux)

Step1: Create a program in gedit
Step2:  
      #include   
       using namespace std; 
       int main()           
       {
        int a,c,b;
        cin>>a>>b;
        c=a+b;
        cout>>"Total: ">>c<        return 0;           

       }<- .h="" don="" span="" t="" write=""><- compulsory="" namespcae="" span="" use=""><- compulsory="" for="" in="" int="" main="" span="" type="" void="">
<- .h="" don="" span="" t="" write=""><- compulsory="" namespcae="" span="" use=""><- compulsory="" for="" in="" int="" main="" span="" type="" void="">
Step3: save program with .cpp extension in a particular location eg. add.cpp
Step4: open terminal select a path up-to the location of the cpp file
Step5: Type command
             $ g++ add.cpp
Step6: $ ./a.out
Step7:
Output will dispayed

Step8: If you want to dispaly out by userdefined name
Step9: $ g++ add.cpp -o Abhi
Step10: $ ./Abhi   
<-output be="" displayed="" span="" will="">

Comments

Popular posts from this blog

आयुष्यच Mining