December 9, 2024

Writing the first C Program

Excited to write C program? Have you downloaded C Compiler? If not, please download the software. Or else, you can use the online C compiler, which is provided by many website.

Note: If you are writing the C program in windows OS, writing the sample C program is already covered in the article: Installing C Compiler on Windows OS Please refer it:

If you are using Ubuntu or any other Linux OS, follow these steps.
Write the below code in notepad. Save the file as hello.c (You can give any name to the file. But there must be .c extension)

#include <stdio.h>
 
int main()
{
    printf("Hello, World!");
    return 0;
}

Now we will compile the C program. Open terminal, go to the location where you have saved the file hello.c Type the command:
gcc hello.c
If there is no compile time error, compiler will create the executable file. Here, it will create the executable a.out file in the same directory.

Run the C executable by using the command ./a.out


Leave a Reply

Your email address will not be published. Required fields are marked *