This post describes about how to complile and execute a C program on Linux system using the gcc compiler with a simple program
Press Windows Key,
type the name terminal on Search field,
Open the "termintal",
Write simple code :
For example I have created a C program file with name of linuxfaq.c and added below lines,
$ gedit linuxfaq.c
#include <stdio.h>
int main( )
{
int value1, value2, total;
printf("Enter two integers: ");
scanf("%d %d",&value1,&value2); /* Enter the two integer */
total=value1*value1; /* multiplay the two values and and stores it in variable sum */
printf("Total: %d",Total); /* Displays total values */
getch();
return 0;
}
Compile :
Now, save and compile that program on terminal,
$ gcc -o linuxfaq linuxfaq.c
the above command will invoke the GNU C compiler to compile the file hello.c, then get output ( -o ) the result to an executable called linuxfaq
Execute :
Type the command and enter the values.
$ ./linuxfaq
Enter two integers: 192
10
Total: 36864
Comments (0)