First check for the compiler installation as follows on your terminal:
[g++ --version]
if it gives the version of your compiler then run the programs as given below other wise just go through this tutorial:
Installing C/C++ compiler in Ubuntu
Running a c++ program
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello world"<<endl;
}
[g++ --version]
if it gives the version of your compiler then run the programs as given below other wise just go through this tutorial:
Installing C/C++ compiler in Ubuntu
Running a c++ program
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello world"<<endl;
}
Save it as first.cpp on your desktop.
Open the terminal and do as follows.
[g++ Desktop/first.cpp -o Desktop/first.o]
^
first.o will be created if no error occurs
[cd Desktop]
[./first.o]
Running a C program
#include<stdio.h>
//using namespace std;
int main()
{
printf("Hello world\n");
}
Save it as second.c on your Desktop.
[g++ Desktop/second.c -o Desktop/second.o]
[cd Desktop]
[./second.o]
Here you can use gcc or g++ as g++ supports both.
If you have any question then write down the comments,I will be pleased to help you.