TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C Tutorials

Getting Started with the First C Program

Overview

Let us see how to write a basic first C program that says “Hello, world!” on the console using CodeBlocks IDE on Windows. You need an editor to code your program. Editors like Notepad++, TextPad, etc, and for serious programming consider using IDE’s like Eclipse, CodeBlocks etc. If you use a text editor you need to perform most of the tasks manually.

Create a New Project

Add a new C file and save the source file as “hello.c”. A C source file should be saved with a file extension of “.c”. A Thumb rule, you should choose a filename that reflects the purpose of the program.

C program

/*

* C program to say Hello World!

*/

// Standard header file to perform I/O operations

#include <stdio.h> // preprocessor directive

// main function . The program entry point. This is like your main door to your apartment.

int main() {

printf("*****************\n"); // Prints *'s

printf("Hello World!\n"); // Prints Hello World!

printf("*****************\n");

return 0; // terminate the main() function

}

// End of main() function

 

Build the Project: Executable Code: Compile and build the source code “hello.c” into executable code in Windows To build the project Hit the Build menu option (Ctrl -F9)  

 

 

————–

Build: Debug in SampleProject (compiler: GNU GCC Compiler)————— i686-w64-mingw32-gcc.exe -Wall -g -march=i586 -c C:\CODEBLOCKS64\SampleProject\hello.c -o obj\Debug\hello.o i686-w64-mingw32-g++.exe -o bin\Debug\SampleProject.exe obj\Debug\hello.o Output file is bin\Debug\SampleProject.exe with size 117.34 KB

————–

 

If you are using text editor with the GCC compiler, start a command prompt, change directory to your work location and issue the command, something like below: /> gcc -o hello.exe hello.c

Run the Executable Code. To run the project Hit the Run menu option (Ctrl -F10)  

 

The IDE used in the program is Code:: Blocks. To download and install Code Blocks follow the link:

https://www.testingdocs.com/download-and-install-codeblocks/

For more information on Code Blocks IDE, visit the official website of Code blocks IDE: http://www.codeblocks.org/

Related Posts

Dissecting a C program

C Tutorials /

Dissecting a C program

C Hello World Program

C Tutorials /

C Hello World Program

In this post, we will develop C Program to generate Fibonacci sequence into rows and columns as output. We get the Fibonacci sequence nth term

C Tutorials /

C Program to generate Fibonacci sequence into rows and columns

Sum of Even Numbers C Program

C Tutorials /

C program to find sum of even numbers from 1 to n

Understanding a Simple C Program

C Tutorials /

Understanding a Simple C Program

‹ C Hello World Program› Dissecting a C program

Recent Posts

  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • RAPTOR Editions
  • Flowgorithm Conditional Breakpoint Statement
  • Flowgorithm Read Numbers from File Example
  • Search Text File Flowchart Example
  • Flowgorithm Turtle Graphics Symbols
  • Draw Circle using Flowgorithm Turtle
  • Draw Parallel Lines using Flowgorithm Graphics

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version