Skip to main content

Basic Meaning Full Information About C-Language

Importance of C:
  • C is a general purpose, structured programming language.
  • C is robust language whose rich set of built in function and operators can be used to write any complex program.
  • C has the ability to write very concise source programs. Mainly because it has a large number of operators a small set of instructions and extensive library functions.
  • It’s well suited for writing both system software and business packages.
  • Program written in C are efficient and fast. This is due to its variety of data types and powerful operators.
  • C is highly portable because C program written for one computer can be run on another with little or no modification.
  • C language is well suited for structured programming. This modular structure makes program debugging, testing and maintenance easier.
  • Another importance feature of c is its ability to extend itself.
  • We can continuously add our own function to the c library.
  • C compiler is commonly available for all types of computer having different platform micro-processor and different operating system.
To Open “C” Command Prompt
C:\TC\BIN\TC.EXE
To open “C” New Program
File->New OR  Alt+F1
To Execute “C” Program
Alt + F9
To Run “C” Program
Ctrl + F9

Let’s see one sample program.
Sample C Program:
  • Ø Printing a Message “Hello Friends, how are you?”

#include
Main ()
{
          /* ----------- Printing Begins -------------- */
                   Printf (“Hello Friends, how are you?”);
          /* ----------- Printing Ends-------------- */

}

  • #include ::
  • Stdio.h refers to the standard input\output header file containing standard input and output functions. That includes functions like ‘printf ()’.
  • #include is a ‘preprocessor directive’. That links program with ‘C Compiler’.

  • Ø Main()  ::
  • The Main () is a special function used by the C system to tell the computer where the program starts.
  • Every program must exactly one main function.not totally true,,,without main function also program start ,,in some exception case.
  •  Function body contains setoff instructions to perform he given task.
  • /* ----------- */ are known as comment lines, that is known as “Multiple Comment Lines”.
  • This is used in a program to enhance its readability and understanding.

  • Ø Printf() ::
    • The only executable statement of the program.
    • Printf is a predefined, standards c function for printing output.
    • Predefined means that it is a function that has already been written and compiled, and linked together with our program at the time of linking.
    • (“ “) Parenthesis is called the argument of he function.

  • Ø Define instructions ::
    • A #define instruction defines value to a symbolic constant for use in the program.
    • A #define is a compiler directive and not a statement.
    • #define lines should not end with the semicolon.
    • Symbolic constant are generally written in uppercase so that they are easily distinguished from lowercase variable names
    • #define instruction are usually placed at the beginning, before the main () function.
    • Symbolic constant not declared in declaration section.
    • Must note that the define constants are not variables.
Basic structure of C Program:
  • C program can be viewed as a group of building blocks called function.
  • A function is a subroutine that may include one or more statements designed to perform a specific task.


Documentation section
Link section
Definition section
Global declaration section
Main() function section
                                 {
Declaration part
Executable part
                                  }
Sub program section

Function 1
.
.
.
.
Function n

  • Ø Documentation section ::
The documentation section consists of a set of comment lines given the name of the program.

  • Ø Link section ::
The link section provides instructions to the compiler to link functions from the system library.

  • Ø Definition section ::
The definition section defined all symbolic constants.

  • Ø Global declaration section::
There are some variables that are used in more than one function such variable are called global variables and are declared in the global declaration section that is outside of all the functions.

  • Ø Main() function section ::
    • Every C program must have one main() section
    • This section contains two parts.
      • Declaration part
      • Executable part
      • The declaration part declares all the variables used in the executable part.
      • All statements in the declaration and executable part end with a semicolon.
    • Ø Sub program section
      • The subprogram section contains all the user-defined functions that are called in the main function.
      • User defined functions are generally placed immediately after the main function, although they may appear in any order.




Executing a ‘C’ program:
  1. Creating the program.
  • As we seen earlier how to start ‘Turbo C’. Then open a new file (file à new) or press (alt + f).
  1. Save the program.
  • After writing a program to save the program follows some steps :
  1.                                              I.    Go to (file à save à drivename:\foldername\programname.C) save the file in C with the extension “.C” not with ‘CPP’.
e.g.  (D:\ exercise1\ prog1.C)
  1.                                            II.    Shortcut key to save program is “f2”.
  2. Compiling the program.
  • We know what compilation is. Here we have a steps for compilation of program :
  1.                                              I.    Compile à compile
  2.                                            II.    Shortcut key is “alt + f9 “.
  3. Linking the program with functions that are needed from the c library.
  4. Executing the program.
  • Compilation done before program executes and it provides syntax error. Then program executes with,
  1.                                              I.    Run à run.
  2.                                            II.    Shortcut key is “ctrl + f9 “.
If program is correct then it provides perfect output but if there is any mistake in program it provides an error. That is logical error.
  1. Debugging the program.
  • To check the program line by line we do debugging. Press “f8”. It will give the information at which line an error has been occurred.
  1. Open the existing program.
  • file  à open  à drivename:\foldername\filename.C
After writing drive name you got all the folders contained in the particular drive and folder shows all the files it contains, so just select particular file from the folder to open the file.

Process of Compiling, Linking and Execution of ‘C Program’:
  • Once the program has been entered into the computer , edited and saved, it can be compiled ,linking and executed by selecting Run from the run menu as we see earlier.
  • The program can be created using any word processing software in non-document mode. After creation of the program should save and the name of program should end with the character ‘.C’ for e.g. program1.c, then the OS load the program stored in the file program1.c and generate the object code.
  • This code is stored in another file under name program1.obj. In case any language errors are found, the compilation is not completed. Then the changes made in the existing program and recompiled it.
  • Then the linking is done which generates executable code with the file name program1.exe. Now the correct program executes and provides the result.      
  • There is a process how the ‘C Program’ starts, compiles, links and executes.
  • As we will see in the process program starts, edited then compiled, we know what is compilation but after that we seen syntax error and the other type of error in process is logical or data error.So,we note that there are two types of error 1) Syntax error 2) Logical or data error.
  • Syntax error: Syntax error is the error in the syntaxes of the ‘C’ program that means ‘turbo C’ provides us some patterns and rules to write a program, if any mistake happened in that pattern then it creates Syntax error.
  • The most important thing is Syntax error provides by Compiler before program links with system library.
  • Only Syntax error provides by compiler after compiling the program.
  • Logical error: Logical error is the error in user’s logic that means error in the code written by user’s mind.
  • Execution shows both the errors logical and syntax.

Comments

Popular posts from this blog

Quiz 1 : Mobile Application Development - Android

Download PDF Version From Here   MCQ 1. Select a component which is NOT part of Android architecture. a. Android framework   b. Libraries          c. Linux kernel   d. Android document 2. What is AAPT? a. Android Asset Processing Tool.             b. Android Asset Providing Tool.   c. Android Asset Packaging Tool.             d. Android Asset Packaging Technique 3. Required folder when Android project is created. a. build                 b. build/               c. bin     d. bin/ 4. Adb stands for   A. Android Drive Bridge.                              B. Android Debug Bridge.            C. Android Destroy Bridge.                          D. Android Delete Bridge. 5. Is list data type supported by AIDL? a. Yes    b. No 6. Component which is NOT under the Android application. a. Content providers      b. Resource externalization         c. Applications d. Notifications 7. Language which is supported by Android for application dev

IP Delivery Concept

It is the practice of using the IP, the network address of the connecting computer, whether robot or human, and sending different content based on that. The database used to assist with the process. In the case of geo-targeting: Databases stores various ranges of IP addresses, and indicates where this ranges of IPs are in the world. A geo-targeting script scans the list to see in which country the current IP is located. Programmer can use this value to effect changes in presentation or logic. In the case of cloaking : Databases stores the IP addresses of the various spiders that may hit your site. The cloaking script scans the list to see if the current IP is a spider. The programmer can use this information to effect changes in presentation or logic. Implementations of IP-delivery-based cloaking also look at the User-Agent header of the request. The user agent header is a header sent by both browsers and spiders. But it is not regarded authoritative, bec

Never try to go back and repair the past which is impossible. But be prepared to construct the future which is possible.

Never try to go back and repair the past which is impossible. But be prepared to construct the future which is possible.