Program Dev C++ Hello World

// A hello world program in C. The first line in our program is a comment line. Every line that starts with two slash signs ( // ) are considered comments and will have no effect on the behavior or outcome of the program. (Words between /. and./ will also be considered as comments (old style comments)). Mar 23, 2020 Hello, World! The main function is a mandatory part of every 'C' program. To use the functionality of a header file, we have to include the file at the beginning of our program. Every 'C' program follows a basic structure.

-->

This sample application shows how to create a minimal Windows program.

Description

The Windows Hello World sample application creates and shows an empty window, as shown in the screen shot that follows. This sample is discussed in Module 1. Your First Windows Program.

Hello

Downloading the Sample

This sample is available here.

To download it, go to the root of the sample repo on GitHub (microsoft/Windows-classic-samples) and click the Clone or download button to download the zip file of all the samples to your computer. Then unzip the folder.

To open the sample in Visual Studio, select File / Open / Project/Solution, and navigate to the location you unzipped the folder and Windows-classic-samples-master / Samples / Win7Samples / begin / LearnWin32 / HelloWorld / cpp. Open the file HelloWorld.sln.

Once the sample has loaded, you will need to update it to work with Windows 10. From the Project menu in Visual Studio, select Properties. Update the Windows SDK Version to a Windows 10 SDK, such as 10.0.17763.0 or better. Then change Platform Toolset to Visual Studio 2017 or better. Now you can run the sample by pressing F5!

Related topics

Here,is a Hello World program in C

Here is the code explanation:

Program Dev C++ Hello World Video

Pre-processor directive

#include is a pre-processor directive in 'C.'

#include <stdio.h>, stdio is the library where the function printf is defined. printfis used for generating output. Before using this function, we have to first include the required file, also known as a header file (.h).

You can also create your own functions, group them in header files and declare them at the top of the program to use them. To include a file in a program, use pre-processor directive

File-name is the name of a file in which the functions are stored. Pre-processor directives are always placed at the beginning of the program.

The main function

The main function is a part of every 'C' program. We can represent the main function in various forms, such as:

  • main()
  • int main()
  • void main()
  • main(void)
  • void main(void)
  • int main(void)

The empty parentheses indicate that this function does not take any argument, value or a parameter. You can also represent this explicitly by placing the keyword void inside the parentheses. The keyword void means the function does not return any value, in this case, the last statement is always getch ().

In the above example, the keyword int means the function will return an integer value. In this case, the last statement should always return 0.

The source code

After the main function has been declared, we have to specify the opening and closing parentheses. Curly brackets { }, indicate the starting and end of a program. These brackets must be always put after the main function. All the program code is written inside these brackets, such as declarative and executable part.

The printf function generates the output by passing the text 'Hello World!'

The semicolon ; determines the end of the statement. In C, each statement must end with a semicolon.

So we have successfully installed the compiler and now can begin working in 'C.' We will write a simple program that will say hello to us. Let's start.

How to run C Program

Step 1) Create a new Project

Step 2) In the pop-up,

  1. Select File
  2. Choose the 'C/C++ Source'
  3. Click 'Go.'

Step 3) Continue, by clicking on 'Next.'

Step 4) To create the new file ,select a 'C' file then click on 'Next' button to continue.

Step 5) Set the file path by clicking the '...' button, the explorer window permits to create the C file.

Step 6) Select the path of your new C File then its name which has .c extension and save it.

Step 7) Finally, to confirm the C file creation click 'Finish.'

Step 8) Enter the code, save it and compile it by clicking on the 'Build & Run 'button.

Here is the result:

Summary

Dev C++ Program Download

  • The main function is a mandatory part of every 'C' program.
  • To use the functionality of a header file, we have to include the file at the beginning of our program.
  • Every 'C' program follows a basic structure.