C – Language History & Basics
· The C programming language
was developed at Bell Laboratories in 1972 by Dennis Ritchie
· C programming language
features were derived from an earlier language called “B” (Basic Combined
Programming Language – BCPL)
· C language was invented for
implementing UNIX operating system
· In 1978, Dennis Ritchie and
Brian Kernighan published the first edition,"The C Programming Language” and
commonly known as K&R C
· In 1983, the American
National Standards Institute (ANSI) established a committee to provide a
modern, comprehensive definition of C.The resulting definition, the ANSI
standard, or “ANSI C”, was completed late 1988.
Ø C language is one of
the powerful language. Below are some of the features of C language.
·
Reliability
·
Portability
·
Flexibility
·
Interactivity
·
Modularity
·
Efficiency and Effectiveness
USES OF C PROGRAMMING LANGUAGE:
Ø The C programming
language is used for developing system applications that forms a major portion
of operating systems such as Windows, UNIX and Linux. Below are some examples
of C being used.
·
Database systems
·
Graphics packages
·
Word processors
·
Spreadsheets
·
Operating system development
·
Compilers and Assemblers
·
Network drivers
·
Interpreters
Levels of Programming Languages:
Ø
There are 3 levels of programming languages. They are,
1. Middle Level languages:
Middle level languages don’t provide all the built-in functions found in high level languages, but provides all building blocks that we need to produce the result we want. Examples: C, C++
Middle level languages don’t provide all the built-in functions found in high level languages, but provides all building blocks that we need to produce the result we want. Examples: C, C++
2. High Level languages:
High level languages provide almost everything that the programmer might need to do as already built into the language. Example: Java, Python
High level languages provide almost everything that the programmer might need to do as already built into the language. Example: Java, Python
3. Low Level languages:
Low level languages provides nothing other than access to the machines basic instruction set. Example: Assembler
Low level languages provides nothing other than access to the machines basic instruction set. Example: Assembler
C LANGUAGE IS A STRUCTURED LANGUAGE:
Ø Structure oriented
language:
· In this type of language, large programs are divided into small
programs called functions.
·
Prime focus is on functions and procedures that operate on the data.
·
Data moves freely around the systems from one function to another.
·
Program structure follows “Top Down Approach”.
·
Examples: C, Pascal, ALGOL and Modula-2.
Ø Object oriented
language:
·
In this type of language, programs are divided into objects.
· Prime focus is in the data that is being operated and not on the
functions or procedures.
·
Data is hidden and cannot be accessed by external functions.
·
Program structure follows “Bottom UP Approach”.
·
Examples: C++, JAVA and C# (C sharp).
Ø Non structure oriented
language:
· There is no specific structure for programming this
language. Examples BASIC, COBOL, FORTRAN.
C PROGRAMMING BASICS TO WRITE A C PROGRAM:
Ø Below are few commands and syntax used in C programming to write a simple C program. Let’s see all the sections of a simple C program line by line.
C PROGRAMMING BASICS TO WRITE A C PROGRAM:
Ø Below are few commands and syntax used in C programming to write a simple C program. Let’s see all the sections of a simple C program line by line.
C Basic
commands
|
Explanation
|
#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
|
#include<conio.h>
|
This is a preprocessor command that includes console input output header file(conio.h)
from the C library before compiling a C program
|
main()
|
This
is the main function from where execution of any C program begins.
|
{
}
|
This indicates the beginning & ending of the main
function.
|
/*_some comments_*/
|
whatever is given inside the command “/* */” in
any C program, won’t be considered for compilation and execution.
|
Clrscr()
|
This Is built-in-function which Clear the output screen before
executing the program.
|
printf(“Hello
World! “);
|
printf command prints the output onto the screen.
|
scanf(“string type”,& variable name);
|
This command Is used to get any data from the user.
|
getch();
|
This command waits for any character input from keyboard.
|
Eg. printf("Enter Number="); scanf("%d",&a); | Here the printf statement will print "Enter Number=", Through scanf user can put the number. |
BASIC STRUCTURE
OF A C PROGRAM:
Ø Structure of C program
is defined by set of rules called protocol, to be followed by programmer while
writing C program. All C programs are having sections/parts which
are mentioned below.
1.
Documentation section
2.
Link Section
3.
Definition Section
4.
Global declaration section
5.
Function prototype declaration section
6.
Main function
7.
User defined function definition section
Example OF
Basic Structure Program:
/*
Documentation
section
C
programming basics & structure of C programs
*/
#include
<stdio.h> /* Link section */
int total = 0; /* Global declaration, definition section */
int sum (int, int);
/*
Function declaration section */
void main () /* Main function */
{
clrscr();
printf
("This is a C basic program \n");
total = sum (1, 1);
printf ("Sum of two numbers : %d \n", total);
getch();
}
int sum (int a, int b) /* User defined function */
{
return a + b; /* definition section */
}
|
click here to know more updates |
No comments:
Post a Comment