Tuesday, 28 November 2017

Basic Programming in C

In this basic programming section, we are going to read about the basic structure of a normal C Programming. The first and simple C Programming is to print the Hello World program. Also, read the basic commands of a program.

1. The Basics of C Programming to write a Program:


Basic commands Description
#include <stdio.h> This is a preprocessor command that includes standard input output header file(stdio.h) from the C library. Before compiling a C program we have to add this library function at first to the C program.
int main() This is the main function from which the execution begins.
{ This indicates the beginning of a function.
/*_multiline_comments_*/ This is the comment command for multiple lines. Whatever is given inside the command “/*   */” in any C program, won’t be considered for compilation and execution. This includes multiple lines.
//_sinlgle line_comments_ This is the comment command for a single line. Whatever is given inside the command “// ” in any C program, won’t be considered for compilation and execution. But this includes only a single line comment.
printf(“Hello_World! “); The printf() function prints an output to console.
getch(); This function waits for a character from the keyboard. 
return 0;
This command terminates C program and returns 0.
}
This indicates the end of the function.

2. A Simple Program to Print "Hello World":

The program written below is a very simple program which would print "Hello World" in the output window. All the syntaxes of C Programming are case sensitive and each line ended with a semicolon (;). The semicolon is used as a terminator line.

Source Code:




Output:


Hello World

3. Steps to Write a C Program and Get the Output:

These are the folloing steps to get the output of a C Programming.
  1. Create.
  2. Compile.
  3. Execute or Run.
  4. Get the Output.