I have to do a program for my C++ class, and we have to write all programs using gedit on ubuntu and run them all using the terminal command prompt. I dont know what the whole ./a.out is, and all i have for my program is

// This program will calculate an employee's total annual pay.
#include <iostream>
using namespace std;

int main ()
	double payAmount, payPeriods,annualPay;

	payPeriods = 26;
	payAmount = 1700.0;
	annualPay = payPeriods * payAmount
	cout << "Employees annual pay is $" << annualPay<< ".\n"	
	return 0;

how do i run it?

a.out is the executable program's name when you don't specify a program name. You can't run an uncompiled C++ program. You can only run something that has been compiled into machine code. You compile with the g++ command.

You start with a C++ program like you have done. Let's say the name of it is my_program.cpp. Let's say you want the compiled program to be my_executable.

You can edit it in gedit. Then at the cmmand line, type this:

g++ my_program.cpp -o my_executable

Type the "ls -l" command at the prompt and you should now see a new file called "my_executable". Note that it will be flagged as executable (i.e. there will be an "x" next to the filename. Note the lack of an "x" next to "my_program.cpp". To run it, type this:


The ./ means "run this program". What follows is the name of the program. If you type this:

g++ my_progam.cpp

the executable will be named a.out and you'll do this:

commented: Well explained +3