Вы находитесь на странице: 1из 5

C - programming

A brief history of c
C programming language is perhaps the most popular

programming language. C was created in 1972 by Dennis Richie on a DEC PDP-11 That was used in the Unix operating system .c is a development process that started with an older language call BCPL.BCPL was invented by Martin Richards, and it is influenced a language called B , which was created by Ken Thompson. B is the development of C in 1970s C is a programming language was first described In the programming language by Brian Kernighan and Dennis Ritchie (Englewood cliffs, N.J.:Prentice-Hall, in 1978) in the summer at 1983 a committee was established to create an ANSI (American National standards institute) standard world define the language The ANISIC standard was finally adopted in December 1989, The standard was also adopted by ISO (international standard organization),and the resulting standard was typically referred to as ANSI/ISO standard C)

C is a middle level language


C is a middle level language because it combines the best elements of high level- language because it combines the best elements of high level languages with the control and flexibility of assembly language . It is less powerful, harder to use ,or less developed than high-level language such as BASIC or Pascal, nor does it imply that C has the cumbersome nature of assembly language Generally there are two major types of languages are available are as follows: 1.Low level languages 2.The set of commands available in low level is compl ex and not easy to understandable. In this category " Assembly " and " machine codes " are available. Assembly programs are faster than other high-level language programs.3. High level languages The set of commands available in high level language is very simple and easy to understandable. High level languages are further divided into two major categories.

1. Procedure Oriented language 2.In this category we are able to create our project or programs using procedural approach means in this type we can able to divide our big project/program into small subroutines or procedures. After making procedures we can able to call a procedure one or more places. The lists of procedural languages are as follows: C language C++ (Object Oriented) Java (Objected Oriented) Smalltalk (Objected Oriented) Pascal language 3. Non-Procedural Languages: This category also known as Problem Oriented languages. In this type of languages we can able to make program only at specific range like database. The followings are the examples of Non procedural language

C Programs Skeleton (General)


<Preprocessor Directives (some time necessary)> <Macros Definition (optional)> <function declaration>

Some common rules for writing C program


Use all commands or statements in lower or small case. After completion of a statement excluding main () or loops must insert ; (semicolon) as a statement terminator. Dont use/declare identifier or variable name same as statement name suppose int include; this is a wrong statement because include has a special meaning in the language

Header Files or Preprocessor Directive contains references or links of library functions. That is built-in in the C language

Suppose if you want to use a function clrscr () ; in the main function so must bedeclared on top # include <conio.h> other wise you could have an prototype error.

Some header files are as follows


Stdio .h Conio.h Dos.h String.h Stdlib.h And many more header files are available in C void main(void) Every C programs consists of one or more functions. No matter how many functions there are in a C program , main is the one to which control is passed from the operating system when the program is run ; it is the first function executed. The word "void" preceding "main" specifies that the function main()will not return a value. The second "void," in parenthesis , specifies that the function takes no arguments. Print f() Print f() is built-in function we can display with print f() any message, variable value on screen/file/printer. In print f() we can use many escape sequences and format specifies. Escape sequences are special notations through which we can display our data Variety of ways: Some escape sequences and their functions are as follows:

Escape Sequence \n \t \ \ \r \b

Description perform line feed & Carriage return operation Prints a tab sequence on screen Prints a single quote character on screen Prints a double quote character on Screen Perform carriage return operation Remove one character from left

Example print f("A\nB"); print f("A\tb"); print f ("\a\") print f ("\"a\""); print f ("a\rb") printf ("a\bHi!" )

Example Program # 1 :


void main (void) {

#include <stdio .h> #include <conio .h>

Print f( " Example Program

(Escape Sequence) \n");

printf( " -----------------------------------------------\n"); printf( "Escape sequnce \t Meaning\n"); printf( " -------------------------------------------------\n"); printf(" \\\\ \t \\" \n"); printf(" \\\ \t \ \n"); printf(" \\\" \t \" \n"); printf(" \\n \t line feed & carriage return\n "); printf(" \\t\t Tab characters or eigth spaces\n");

printf(" \\b\t Erase one char from right to left\n"); printf(" \\r\t perform only line feed\n"); getch();} } This program produces following output Example Program (Escape Sequence) -------------------------------------------Escape Sequence Meaning \\ \ \ \" \" \n line feed & carriage return \t Tab Characters or eight spaces \b Erase one char from right to left

\r perform only line feed

Вам также может понравиться