Monday, August 27, 2018

C "Hello, World!" Program | Explanation of hello world program in c


C "Hello, World!" Program | Explanation of hello world program in c

Introduction – “hello, world” This is an exercise for creating your very first Alice program. This exercise is good for creating you very first computer program or your very first computer program in Alice. You may want to reference the lesson Programming in Alice or the Code Editor How to resources. These materials can be downloaded and printed for offline use from Alice.org The History of “hello, world” A “hello, world” program has a long history in computer science. It is commonly used as a program that can be created to show that a programming environment is properly working but also to prove that you have learned enough about a programming language that you can make this program work and display hello, world. This program has a long history with novice programmers as being their very first executed program. The actual origin of the program dates back to the late 1960’s and early 1970’s with some debate as to the very first use but has been attributed to Brian Kernighan and Martin Richards. It is documented as an example program in the book The C Programming Language
#include main( ) { printf("hello, world\n"); Adding an Object The first step will be to add an object to your scene. You may wish to watch the Videos or check the Quick Reference Guides for the How To: Adding Objects to a Scene 1. Start Alice 2. Select the a template from the Blank Slates section of the Select Template Dialog box. 3. Click on the Setup Scene button to go to the Scene Editor of Alice. 4. Add a character of your choice by double clicking it and adding it to the center of the scene or dragging and dropping it into the world 5. Click on the Edit Code button to return to the Code Editor Adding a Procedural Method (statements) Next you will write your very first Alice program. You may wish to watch the Videos or check the Quick Reference Guides for the How To: Using Procedures Overview. 6. Select your character from the object menu of the methods panel. 7. Drag the say tile into the myFirstMethod tab of the editor. 8. Select the Custom TextString from the pop up drop down. 9. Input “hello, world” in the input field. 10. Save the project. Run Your Program Next you will run your program and officially become an Alice/Computer programmer! 11. Press the Run button found on the camera view window. Congratulations!

A simple C program to display "Hello, World!" on the screen. Since, it's a very simple program, it is often used to illustrate the syntax of a programming language.

To understand this example, you should have the knowledge of following C Programming topics:
Program to Display "Hello, World!"
#include <stdio.h>
In main ()
{
   // printf () displays the string inside quotation
   Printf ("Hello, World!");
   return 0;
}
Output
Hello, World!
How "Hello, World!" program works?
  • The #include <stdio.h> is a preprocessor command. This command tells compiler to include the contents of stdio.h (standard input and output) file in the program.
    The 
    stdio.h file contains functions such as scanf() and print() to take input and display output respectively.
    If you use 
    printf() function without writing #include <stdio.h>, the program will not be compiled.
  • The execution of a C program starts from the main() function.
  • The printf() is a library function to send formatted output to the screen. In this program, the printf() displays Hello, World! text on the screen.
  • The return 0; statement is the "Exit status" of the program. In simple terms, program ends with this statement.


  • 0Blogger Comment
  • Facebook Comment

Post a Comment