Basics to write C program

Hello friends I’m here with another important article on C which will give you idea about how to write a C program and what are the different parts  in it 🙂

This article includes following points                    1) Special characters in C.   2) Character set in C.                       3) Structure of C.          4)Sample program of C.                  

• Some special characters are used in C, and they have a special meaning which
cannot be used for another purpose.
 •1)Square brackets [ ]: The opening and closing brackets represent the single  and multidimensional subscripts.                                           
•2) Simple brackets ( ):  It is used in   function declaration and function calling.
•For example, printf() is a pre-defined function.
•3) Curly braces { }:  It is used in the opening and closing of the code. It is used in the opening and closing of the loops.
 •4)Comma (,):  It is used for separating for more than one statement and for example, separating function parameters in a function call, separating the
variable when printing the value of more than one variable using a single
printf statement.
  •5) Hash/pre-processor (#):  It is used for pre-processor directive. It basically denotes that we are using the header file.

2)Character set of C

Character:- It denotes any alphabet, digit or special symbol used to represent information.

Use:-  These characters can be combined to form variables. C uses constants,variables, operators, keywords and expressions as building blocks to form a
basic C program.

Character set:-    The character set is the fundamental thing of any programming language and they are used to represent information. Like natural
languages, computer language will also have well defined character set, which is
useful to build the programs.
The characters in C are grouped into the following two categories:
a.Source character set
                        a.   Alphabets (A-Z, a-z)
                        b.   Digits (0-9)
                        c.   Special Characters (#,$,;)
                        d.   White Spaces
b.Execution character set
                         a.     Escape Sequence

3)Structure of a ‘C’ program
Parts of C program-
•1)# include <stdio.h> –  This command is a preprocessor directive in C that
includes all standard input-output files before compiling any C program so as
to make use of all those functions in our C program.
 •2) int main() –  This is the line from where the execution of the program starts. The
main() function starts the execution of any C program.
 •3) { (Opening bracket) –  This in dicates the beginning of any function in the
program (Here it indicates the beginning of the main function).
  •4)  /* some comments */ l –  Whatever is inside /*——-*/ are not compiled and
executed; they are only written for user understanding or for making the
program interactive by inserting a comment line. These are known as
multiline comments. Single line comments are represented with the help of 2
forward slashes “//——”.
  •5) printf(“Hello World”) – The printf() command is included in the C stdio.h
library, which helps to display the message on the output screen.
  •6) scanf – scanf function in C which allows the programmer to accept input from the
standard input device (keyboard) and stores them in variables.
  •7) getch() –  This command helps to hold the screen.
  •8) return 0 – This command terminates the C program and returns a null value,
that is, 0.
  •9) } (Closing brackets)-   This indicates the end of the function. (Here it indicates
the end of the main function)   

  4)Sample Program:-(To print Hello World)
#include <stdio.h>
int main()
{
// Our first basic program in C
printf(“Hello World!\n\n”);
return 0;
}

Thank you guys……. Hope you all will find this article useful.
Will meet in next article till then good bye….. Have a nice day. And thank you once again for your support 🙂

You may also like...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: