How to install gcc in ubuntu and run first C program

How to install gcc in ubuntu and run first C program

Here c program demonstrated is simple interest calculator.

Following are quick steps to install gcc

Go to terminal

login as root :

Sudo su

type command : (requires active Internet connection)

apt-get install gcc

Open gedit editor.


Type C Program & Save with .c extension. Download firstcprogram.c (114 downloads)


int main()

	//program to calculate simple interest. formula is i=(p*n*r)/100;

	//p is principal amount
	//i is interest amount
	//r is rate of interest 
	//n is no. of years.

	double p,n,r,i;

	printf("\n\t ENTER PRINCIPAL AMOUNT : ");

	printf("\n\t ENTER RATE OF INTEREST : ");

	printf("\n\t ENTER TERMS : ");


	printf("\n\t INTEREST CALCULATED IS %lf\n",i);

	return 0;

Compile C Program

gcc -o firstprogram firstcprogram.c

To run program



This video shows simple steps to install gcc compiler on ubuntu 16.04 and run first C program for beginner.