Basic Structure OF C Program with Example

In This article we will learn about the Documentation In C Programming Language OR Basic Structure Of C Language With Example After Reading this article you will be able to define about Documentation Section In C, Link Section In C, Definition Section In C, Main Function Section In C And  Subprogram Section In C, What is Documentation Section In C.



Basic Structure OF C Language:

Each C Program is consists of 6 main sections, these sections are named as Documentation Section, Link Section, Definition Section, Global Declaration Section, Main Function Section, Subprogram Section. you will find a brief explanation about each section below.

Basic Structure Of C Language With Example
Basic Structure Of C Programming Language

 - Documentation Section: The Documentation Section consists of a set of comment lines giving the name of the Programmer, date, and other details about the program. The documentation section helps anyone to get an overview of the program. Comments may appear anywhere within a program. The text between /* And */ appears as a comment in C.
for Example: /* This is a comment */

- Link Section: The Link section provides instructions to the compiler to link functions from the system library such as using the #include directive.

- Definition Section: All the symbolic constants are written in the definition section. Macros are known as symbolic constant (macro is a process where an identifier is replaced by a predefined string or value in a program) such as using the #define directive.

- Global declaration section: Global Declaration Section contains the global declaration of user-defined functions and Variables. There are some variables that are used in more than one function. Such variables are called Global Variables and are declared in the global declaration section that is outside of all the functions.

- Main() Function Section: It is necessary to have one main() function section in every c program. This section contains two parts, the Declaration Part And Executable Part.
   The declaration part declares all the variables that are used in the executable part.

- Subprogram Section: The subprogram section contains all the user-defined functions that are used to perform a specific task. These user-defined functions are called in the main function. User-defined functions are generally placed just after the main() function, although they may appear in any order.

Example Of Basic Structure Of C Language:


BAsic Structure OF C Language With Example
Example Of Basic Structure Of C Language
Conclusion:
in this article, we learned about the Basic Structure Of C Language With an Example. Any C Program is consists of 6 main sections that are
  1.  Documentation Section
  2.  Link Section
  3.  Definition Section
  4.  Global Declaration Section
  5.  Main() Function Section
  6.  Sub-Program Section 
If you find that this article is useful for you then please share this article with your friends on Facebook, Twitter or WhatsApp.



Thank You !!

Tags: C Language Basics, C Language for Begginers, Basic Structure OF C Language with an example, Documentation Section OF C Language, Link Section OF C Language, Defenation Section OF C Language,, Global Declaration Section OF C Language,, Main Function Section OF C Language, Subprogram Section OF C Language, Documentation in C Language, SubProgram Section In C, Structure Of C Program, Structure OF C Programming, Documentation In C Language



Variables, Constants And Data Types in C Language

In this article we will learn about What is constant in C Language, Symbolic Constant in C, Variables And Constants In C Language, Types of Constants in C, Define Constant in C, Integer constant in C, Character Constant in C, Variables in C, C Programming VariablesRules for declaring variables in c, Variable declaration in C, Variable Declaration in C, Definition of Variable in C, Variable initialization in C, Variable declaration in C Programming language, Define Constant in C and Difference between constant and variable in c, Secondary Constants In C, Global Variable in C

We Will Also Discuss About the Difference Between Variables and Constants in C Language. Definition Of Constant in C LanguageConstant in C Language with Example.

Constants in C

We know that every software is developed for manage some type of data or information, that data or information is called constants.
Constants in C refer to fixed values that do not change during the execution of a program.
in other words, A constant is a value or an identifier whose value cannot be change in a program. For example: 2, 4, 3.9, 'c', "Hello World", etc.

When we write a program to calculate or find any desired output by using different type of operators get constants as output, For example if we creating a program for calculate factorial of a given number then in this program we will get 120 as our output for the input of 5, in this situation the output i.e. 120 is also an integer constant.

There are two types of constants in C:
  1. Primary Constants
    • Integer Constants
    • Real Constants
    • Character Constants
  2. Secondary Constants
    • Array
    • String
    • Pointer
    • Union
    • Structure
    • Enumerator

Constants in C Language

    Primary Constants are fundamental constants in C and the Secondary constants are the constants which is created with the help of Primary Constants. In this article we will discuss about the sub-categories of Primary Constants, Later on we will learn about Secondary Constants in our future articles.
    Integer Constants: Integer constants are numeric integer values, like 2, 5, 245, -540, 0, -3 etc.
    Real Constants: Real Constants are numeric fractional values, like 3.0, 8.5, 1964.98 etc.
    Note: 2.0 is a Real constant in C.
    Character Constants:   Any single symbol with single quote is called character constants in C, like 'a', '+', '2', 'B' etc.
    Note: '-3' is not a character constant because there is two symbols ( and  3)  similarly 3.0 is also not a character constant because it has three symbols ( 3, . and 0), there must be a single symbol under single quote to be a character constant in c. 

    Variable in C

    When we want to store any data or information in our computer, we store the data in storage devices like hard disk or SSD, similarly in Programming language a programmer store data for perform some operation on that data, the memory location on which the data is stored is known as Variables.
    In simple words, Variables are name given to memory locations. 

     Variables in C

    suppose, we are creating a program for finding the sum of two numbers, then we store that two numbers in memory that we can add them, that memory location on which these numbers are stored, known as variables.
    Let us take the above example of calculating factorial, if we are creating a program for calculate factorial of a given number, then we need to store the given number in memory so that we can perform some operation on that number for find factorial of that number. The memory location where we store that given number will called variable in this situation.
    Programmer can select a meaningful name for variables, like number, height, marks etc.

    Difference Between Constants And Variables in C 

    Constants are values that can not be change during the execution of a programs, whereas variables are name, which is given to memory locations. The value of variables can be change during the execution of a program. 
    Data Type Of Variables:
    A Variable in C language must be given a data type, which defines what type of data the variable will hold
    It can be:
    • int: Used To hold Integer value.
    • float: used to hold fractional numeric value.
    • double: used to hold fractional numeric value.
    • char: used to hold a character, only single character (symbol).
    Rules For Write name of Variable:
    • Variable name must not start with a digit.
    • Variables name contains alphabets, digits and underscore.
    • keywords are not allowed as variable name.
    Declaring, Defining and Initializing a Variable:
    - Declaratio of a variable must be done before they are used in the program. Declaration tells the compiler that what is the name of variable and what is its data type (which type of data that variable can store).
    Syntax: data_type variable_name;
    e.g. int age;
    - Initialization of a variable means to assign a value to the variable, this is done at the time of Declaration or after declaration.
    syntax: data_type var_name=value;

    Conclusion:
    So in this article we learnt about What is constant in C,Variables And Constants In C Language, Types of Constants in C, Define Constant in C, Integer constant in C, Character Constant in C, Variables in C, Rules for declaring variables in c, Variable declaration in C, Variable Declaration and Definition in C, Variable initialization in C, Variable declaration in C Programming language, Define Constant in C and Difference between constant, variable in c, Variable And Data Type In C Language.
    Now you are able to answer What is Integer Constant in C Language

    - Also Read: Basic Structure Of C or C++ Language | Introduction OF Java



    Thank You !!

    Tags: What is variable in C, what is Constant in C, What is Data Types in C, Types of Constants in C, Define Constant in C, Integer constant in C, Character Constant in C, Variables in C, Rules for declaring variables in c, Variable declaration in C, Variable Declaration and Definition in C, Variable initialization in C, Variable declaration in C Programming language, Define Constant in C and Difference between constant, variable in c, Data Type in C Language, Types Of Data in C, Data Types, Secondary Constants in C, What is variable in C, C Programming Constants, Constants And Variables In C Language

    Keywords And Identifiers in C Langugae

    in this article we will learn about the terms Keywords in C Language, Identifiers in C Language, Rules For Naming identifiers in C, Valid And Invalid identifiers in C, Example OF Valid And Invalid identifiers in C And  Types Of identifiers in C. 

    We Will Discuss About the Definition Of Keywords And Definition Of Identifiers in C Language.  we Will Also know about the Difference between Keywords And Identifiers.



    Keywords in C

    Keywords are those words whose meaning is already defined by Compiler. Keywords are predefined words that has special meaning to the compiler. it cannot used as the name of identifier.
    We know that the source code c is firstly translated by compiler to generate executable code and hence it is necessary that compiler can understand each word of the source code, there are two types of words used in source code i.e. Keywords And  identifiers. We will discuss about identifiers later. Keywords are those words whose meaning is already known by Compiler. There are 32 keywords in C. we will discuss about each keywords in our future posts.
    Keywords in C Language

    Main Points:
    • Keywords are those words whose meaning is already defined by Compiler.
    • There are total 32 keywords in C Language.
    • C Keywords are also called Reserved words.
    • keywords cannot be used as identifier name.   
    The meaning of Keywords is already defined to the Compiler, These meaning of Keywords cannot be changed that's why keywords cannot used as identifier, because if they used as an identifier then they will try to change the meaning of keywords which is not possible. 

    Identifiers in C

    Identifiers are name given to entities in Programming Statements, such as variables, functions, structures, etc.

    You can say that A program have many words which are not keywords, they are the name of Variables, functions or other entities which is given by programmer that words are called identifiers in c language.

    For Example:     int Money;
    here Money is an identifier and int is a keyword.

    Rules For Write Identifier Name:

    1. An identifier can only have alphanumeric characters (a-z, A-Z, 0-9) or underscore ( _ )
    2. The first character of an identifier can only contain alphabet (a-z, A-Z) or underscore ( _ ). First Character of an  identifier can not be a digit.
    3. identifiers are also case sensitive in c. for example Num And num  are two different identifiers in c.
    4. Keywords cannot be used as an identifier.
    5. No Special character except underscore is allowed to use in c as an identifier. 

    Difference Between Keywords And Identifiers in C

    Keywords are predefined reserved words, that has special meaning defined by compiler. Keywords can not be used as an identifier.
    An identifier is a unique name given to a variable or a function.
    For Creating a variable both (keyword and identifier) are bind together.
    e.g. int num; 
    here int is a keyword and  num is an identifier.
    Note: Don't worry, we will learn about variable and function in our next articles. 

    Types Of Identifiers in C

    we know that identifier is a user defined name given to a variable or a function, identifiers has two main type on the basis of its meaning i.e. Constants And  Variables. 
    - Constants: In mathematics we have read that constants are those entity whose value does not change. that is also true for programming languages, But in the term of software development we define it in another way.
    Every software is developed for manage some type of data, For example our mobile has a software i.e. Phonebook in which we save our contacts, that software manage Names, Phone Numbers and such things in our mobile that information which is managed by software is called constants.
    There are two types of constants in c language.
    - Variables: Each Program get some memory in RAM (Random Access Memory) when they start executing. They get memory in RAM for mainly two purpose that is too store instructions and too store data. like if there is a statement Add two numbers 2 and 4, here Add is an instruction and  2 And 4 are data. The memory locations in which that data are stored is called variable.
    in short words you can say that variables are name given to memory locations.
    For example, if you are writing a program for find sum of two numbers then you should create three variables, 2 for store data on which you will perform the task and one for store the result.
    in our next post we will discuss about the details of Constants and Variables.

    - Also Read: Introduction To C | Features And Advantage Of C Language


    Conclusion: 
    In this article we learn about Keywords And Identifiers in C, Difference Between Keywords And Identifiers, Rules For Writing An Identifier Name, Types Of Identifier in C, Constants in C,  Variables in C


    - Also Read: Introduction To C++ | Introduction To Java

    Thank You !!

      Tags: Keywords in C, Identifiers in C, Keywords And Identifiers in C, Difference Between Keywords And Identifiers, Rules For Writing An Identifier Name, Types Of Identifier in C, Constants in C, Variables in C, 32 Keywords In C Language, What is Keywords in C, What is Identifiers in C Language

      Compiler And its Requirement For C Or C++

      In this article we will learn about Source Code, Object Code, Byte Code, Machine Code, What is Compiler, What is the requirement of compiler And Work Of Compiler. 

      We will Discuss About the Definition Of Source Code, Definition Of Object Code, Definition Of Machine Code, Definition Of ByteCode
      We will Understand that What is a Compiler and Why we need a Compiler to Develop Any Software or Website.


      Before discuss about Compiler lets talk about some terms which are related with compiler.

      Machine Code: Machine codes are set of instructions which is directly executable (without any translation)  by the computer's physical processor. But the problem with machine code is it is not portable that means machine code for every machine may be different. If a program is written in machine code on a specific machine then it will not execute on another machine, And machine language is not a easy language like C, C++ or Java.

      Byte Code: Byte Codes are that codes which can be executed by a virtual machine. It is slower than Machine Codes but is portable across platform, that means a Byte Code written on a specific machine can be execute and produce same output on any machine or any Operating Systems.
      To Know More About Byte Codes Please Read   Introduction To Java

      Object Code: Object codes are that codes which are generated by Compiler and are containing  machine codes or Byte Codes or combination of both. That are used to produce executable file. That codes are combined with additional meta data like library files and generate executable code.

      Source Codes: Source codes are set of instructions in human readable form. which is used to generate object codes and machine code, like codes in C, C++ or Java. It is easy to learn. 

      Compiler:

      we know that a computer can understand only machine language but it is too difficult to learn machine language and it is also machine dependent language.

       We learn a easy language like C or C++, but computer can not understand it directly, so it is required to convert the C or C++ code into machine code which is understable by computer.

      A compiler is a program (software) that translate a source program which is written in a high level language (such as C, C++ or Java) into machine language. Compiler compiles the whole source code and convert them into object code, later on  the object code is  converted into executable code by combining library files, it also shows syntax errors.

      Compiler

      In other words you can say that compiler is a software which take source file as its input and produce object and executable file as its output.

      C or C++ is a platform dependent language that mean the object code of C or C++ which is generated by a operating system can't execute on another operating system.

      For Example: if you write a program on windows operating system and compile it to get an executable file then the executable file will only run on the machines which have windows operating system, if you want to execute the program on another operating system then you have to compile the source code on that operating system.

      so there are different different compilers for different different operating systems. 
       There are many compilers are available in market for C or C++, like Turbo C++, Dev C++, Codeblocks.

      You Can Download Codeblocks From: http://www.codeblocks.org

      Also Read: Introduction To C | Introduction To C++

      Conclusion: 

      So we learnt about what is source file, what is object file, what is byte code, what is machine code, what is compiler And why compiler is required. 


      - Also Read: Features Of C | Variable And Data Types In C



      Thank You !!

      Tags: What is Source Code, What is Object Code, What is byte code, what is machine code, what is compiler, source file, object file, byte code, machine code, compiler, need of compiler, Requirement of compiler, Advantage of Compiler, Disadvantage of Compiler, Importance Of Compiler

      Introduction To Java Programming

      In this article we will discuss about the History Of Java, Introduction of Java and the Features Of Java. After reading this article you will be able to define about the History Of Java, Basics Of Java and Features of java programming language, We Will Also Discuss About Different  Types of Java Applications, About Java Virtual Machine (JVM) And ByteCode in Java
      Java

      Java is a programming language which was developed by James Gosling from Sun Microsystems in 1991. The purpose of developing Java is to write program once and then run this program on multiple operating systems. Sun Microsystems (A Company in which Java was developed) acquired by Oracle Corporation in 2010 so now Java is a product of Oracle Corporation. The first publicly available version of Java (Java 1.0) was released in 1995. Java programs are platform independent that means the program of Java can execute on any operating system or any machine. Java virtual machine (JVM) executes the code of Java.
      The current version of Java is Java 1.8 which is also known as Java 8.

      Main Points: 
      • Java is an object oriented programming language.
      • It was developed by James Gosling in 1991.
      • The first publicly version of Java was released in 1995 i.e. Java 1.0
      • Now Java is a product of Oracle Corporation.  
      • JVM is required for execute any java program.
      Types OF Java Application:
      1. Web Application: Java is used to develop server side web applications.
      2. Desktop Application: It is also known as the Standalone application or window-based application. An Application which is needed to install on almost every machine such as Antivirus.
      3. Enterprise Application: An Application which has the advantage of high-level security, load balancing, and clustering.
      4. Mobile Applications: Java is used to develop mobile applications. Android Application can also be developed by Java.

      Features OF Java:

      • Object Oriented: Java supports the features of object oriented programming system.
      • Platform independent: Unlike many other programming language including C and C++, java is platform independent language that mean code written in one operating system can execute on any other operating system and machine.
      • Simple: Java has many features of C and C++ that make it simple and easy.
      • Secure: Java provides a wide range of protection from viruses and malicious programs.  It ensures that there will be no damage and no security will be broken.  
      • Portable: Execuation of Same java program on different machine is possible.
      • Multi-Threaded: The multithreading programming feature in Java allows you to write a program that performs several different tasks simultaneously.     
      What is Java Virtual Machine (JVM)?
      Before, we discuss about JVM lets see the phases of program execution. Phases are as follows:
       we write the program, then we compile the program and at last we run the program.

      1) Writing of the program is of course done by java programmer like you and me.
      2) Compilation of program is done by javac compiler, javac is the primary java compiler included in java development kit (JDK). It takes java program as input and generates java bytecode as output.
      3) In third phase, JVM executes the bytecode generated by compiler. This is called program run phase.  
      So the main task of JVM is to execute the bytecode which is produced by compiler. Each Operating System has different JVM however the output produced by them is same in all operating systems. that's why we call that Java is a platform independent language.

      What is bytecode in Java?
      As discussed above Java compiler compiles the source code and produce bytecode so that it can be executed by JVM. The bytecode is saved with .class extension by compiler. 

      Also Read: Introduction To C | Advantage And Features Of C Language

      Conclusion:
      So Now we learnt about the History Of Java, Basics Of Java, What is Java Virtual Machine, What is bytecode in Java And  Features Of Java. 

      - Also Read: Basic Structure Of C Program | Keywords And Identifiers In C Language

      Thank You !!

      Tags: History Of Java, Basics Of Java, Introduction to Java, What is Java Virtual Machine, What is bytecode in Java, Features Of Java, Basic Java, Beginner Guide Java, About Java, Type of Application In Java, Java Virtual Machine, Java Bytecode, What is ByteCode, JVM, JDK, What is java development kit