In order to communicate with the computer user also needs to have a language that should be understood by the computer. for this purpose, different languages are developed for performing different types of work on the computer. C is a general-purpose high level language that was originally developed by Dennis Ritchie for the Unix operating system.
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Introduction to C Programming Language.pptx
1. V.V. VANNIAPERUMAL COLLEGE FOR WOMEN
VALUE ADDED COURSE
Introduction to C Programming Language
Dr. T. Anitha
Assistant Professor
Department of Mathematics(SF)
2. COMPUTER LANGUAGES
In order to communicate with the computer user also needs to have a
language that should be understood by the computer. for this purpose, different
languages are developed for performing different types of work on the computer.
basically, languages are divided into two categories according to their
interpretation.
1. Low level languages.
2. High level languages
3. Low level languages
low level computer languages are machine codes or close to it. Computer cannot understand
instructions given in high level languages or in English. It can only understand and execute
instructions given in the form of machine language i.. Language of 0 and 1. There are two types
of low level languages:
Machine language.
Assembly language
• Machine language: It is the lowest and most elementary level of programming language and
was the first type of programming language to be developed. In fact, a manufacturer designs a
computer to obey just one language, its machine code, which is represented inside the computer by
a string of binary digits (bits) 0 and 1. The symbol 0 stands for the absence of electric pulse and 1
for the presence of an electric pulse . since a computer is capable of recognizing electric signals,
therefore, it understand machine language.
4. Disadvantages of Machine Language:
i) All operation codes have to be remembered
ii) These languages are machine dependent i.e. a particular Machine
language can be used on only one type of computer.
5. Assembly Language
It was developed to overcome some of the many inconveniences of machine
language. This is another low level but a very important language in which
operation codes and operands are given in the form of alphanumeric symbols
instead of 0‟s and l‟s. These alphanumeric symbols will be known as mnemonic
codes and can have maximum up to 5 letter combination e.g. ADD for addition,
SUB for subtraction, START,LABEL etc. Because of this feature it is also known
as „Symbolic Programming Language‟. This language is also very difficult and
needs a lot of practice to master it because very small
6. Disadvantages of Assembly Language
i) Like machine language it is also machine dependent.
ii) Since it is machine dependent therefore programmer Should have the
knowledge of the
hardware also.
7. High Level Languages
High level computer languages give formats close to English language and
the purpose of developing high level languages is to enable people to write programs
easily and in their own native language environment (English). High-level languages
are basically symbolic languages that use English words and/or mathematical
symbols rather than mnemonic codes. Each instruction in the high level language is
translated into many machine language instructions thus showing one-to-many
translation. Examples are
BASIC (Beginners All Purpose Symbolic Instruction Code).
FORTRAN (Formula Translation).
PL/I (Programming Language, Version 1).
8. APL (A Programming Language).
ALGOL (Algorithmic Language)
COBOL (Common Business Oriented Language).
RPG (Report Program Generator)
LISP (List Processing).
Prolog (Program in Logic).
C++
Java
Visual Basic
Visual Java
Visual C
9. INTRODUCTION TO C
C is a general-purpose high level language that was originally developed by
Dennis Ritchie for the Unix operating system. It was first implemented on the
Digital Equipment Corporation PDP-11 computer in 1972 . It was designed and
written by a man named Dennis Ritchie.
C has now become a widely used professional language for various reasons.
• Easy to learn
• Structured language
• It produces efficient programs.
• It can handle low-level activities.
• It can be compiled on a variety of computers.
10. C Program File
All the C programs are written into text files with extension ".c" for
example hello.c. You can use "vi" editor to write your C program into a file.
11. Program
C is a structure programming Language.
General Structure of a C program:
/* Documentation section */
/* Link section */
/* Definition section */
/* Global declaration section */
main()
{
Declaration part
Executable part (statements)
}
/* Sub-program section */
12. Documentation section
The documentation section is used for displaying any information about the
program like the purpose of the program, name of the author, date and time written etc,
and this section should be enclosed within comment lines. The statements in the
documentation section are ignored by the compiler.
It is represented as
/*……………………………..*/
Link section:
The link section provides instructions to the compiler to link functions from the
system library such as using the #include directive.
#include<stdio.h> tells the compiler to include information about the standard
input/output library. The stdio.h (standard input output header file) contains definition
&declaration of system defined function such as printf( ), scanf( ), pow( ) etc.
Generally printf() function used to display and scanf() function used to read value.
13. Definition section:
The definition section defines all symbolic constants such using the
#define directive.
Global declaration section:
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. This section also declares all the user-
defined functions.
main () function section:
Every C program must have one main function from where actually
program is started and it is encloses within the pair of curly braces.
14. Syntax :
main()
{
……..
……..
……..
}
The main( ) function return value when it declared by data type as
int main( )
{
return 0
}
The main function does not return any value when void (means null/empty) as
void main(void ) or void main()
{
printf (“C language”);
}
Output: C language
15. The program execution start with opening braces and end with closing brace.
This section contains two parts; declaration part and executable part
1. Declaration part:
The declaration part declares all the variables used in the
executable part.
2. Executable part:
There is at least one statement in the executable part. These two parts must
appear between the opening and closing braces. The program
execution begins at the opening brace and ends at the closing brace. The closing
brace of the main function is the logical end of the program. All statements in the
declaration and executable part end with a semicolon.
16. /*First c program with return statement*/
#include <stdio.h>
void main ()
{
printf ("welcome to c Programming language.n");
return 0;
}
Output:
welcome to c programming language.
17. A group of instructions would be combined later on to form a program.