9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
Learn C Programming Fundamentals
1. Programming in C GOPIKA S,
KJC
Let us Learn
C Programming
Dr. GOPIKA S
Assistant Professor ,
Department of Computer Science,
KRISTU JAYANTI COLLEGE
1
2. Course Objective:
To familiarize with the concepts of structured programming using C language.
Course Outcomes:
After successful completion of the course, the student will be able to:
construct sequential, iterative solutions for problems
differentiate between decision control structures and loop control structures
distinguish between data representation through arrays, pointers, structures and unions
Text Books:
Balagurusamy.E.Programming in ANSI .(7 th ed.). Tata McGraw Hill.
Kamthane Ashok.(2003).Programming with ANSI and Turbo C.Pearson Education.
Programming in C GOPIKA S, KJC
2
3. What is C Programming Langauge?
C is a general-purpose programming language that is extremely popular, simple,
and flexible to use.
It is a structured programming language that is machine-independent and
extensively used to write various applications, Operating Systems like Windows,
UNIX and many other complex programs like Oracle database, Git, Python
interpreter, and more.
C is a procedural Oriented Language the is base for the programming. If you
know ‘C,’ you can easily grasp the knowledge of the other programming
languages that uses the concept of ‘C’
It is essential to have a background in computer memory mechanisms because it
is an important aspect when dealing with the C programming language.
Programming in C GOPIKA S, KJC
3
4. Programming in C GOPIKA S, KJC
In 1972, a great computer scientist Dennis Ritchie created a new
programming language called ‘C’ at the Bell Laboratories. It was created from
‘ALGOL’, ‘BCPL’ and ‘B’ programming languages. ‘C’ programming language
contains all the features of these languages and many more additional
concepts that make it unique from other languages.
‘C’ is a powerful programming language which is strongly associated with the
UNIX operating system. Even most of the UNIX operating system is coded in
‘C’. Initially ‘C’ programming was limited to the UNIX operating system, but as
it started spreading around the world, it became commercial, and many
compilers were released for cross-platform systems.
Today ‘C’ runs under a variety of operating systems and hardware platforms.
As it started evolving many different versions of the language were released.
At times it became difficult for the developers to keep up with the latest
version as the systems were running under the older versions. To assure that
‘C’ language will remain standard, American National Standards Institute
(ANSI) defined a commercial standard for ‘C’ language in 1989. Later, it was
approved by the International Standards Organization (ISO) in 1990.
‘C’ programming language is also called as ‘ANSI C’.
4
5. Applications of C
‘C’ language is widely used in embedded systems.
It is used for developing system applications.
It is widely used for developing desktop applications.
Most of the applications by Adobe are developed using ‘C’ programming language.
It is used for developing browsers and their extensions.
It is used to develop databases. MySQL is the most popular database software which is
built using ‘C’.
It is used in developing an operating system. Operating systems such as Apple’s OS X,
Microsoft’s Windows, and Symbian are developed using ‘C’ language. It is used for
developing desktop as well as mobile phone’s operating system.
It is used for compiler production.
It is widely used in IOT applications.
Programming in C GOPIKA S, KJC
5
6. Summary
‘C’ was developed by Dennis Ritchie in 1972 in BELL lab.
It is a robust language.
It is widely used in the software development field.
It is a procedure and structure oriented language.
It has the full support of various operating systems and hardware platforms.
Many compilers are available for executing programs written in ‘C’.
A compiler compiles the source file and generates an object file.
A linker links all the object files together and creates one executable file.
It is highly portable.
Programming in C GOPIKA S, KJC
6
7. Structure of a C program
A C program is divided into different sections. There are six main sections to a
basic c program.
The six sections are,
Documentation
Link
Definition
Global Declarations
Main functions
Subprograms
Programming in C GOPIKA S, KJC
7
8. Documentation Section
The documentation section is the part of the program where the programmer
gives the details associated with the program. He usually gives the name of the
program, the details of the author and other details like the time of coding and
description. It gives anyone reading the code the overview of the code.
Example
/**
* File Name: Helloworld.c
* Author: AABBCCDD
* date: 09/08/20121
* description: a program to display hello world
* no input needed
*/
Programming in C GOPIKA S, KJC
8
9. Link Section
This part of the code is used to declare all the header files that will be used in the
program. This leads to the compiler being told to link the header files to the system
libraries.
Example
#include<stdio.h>
Definition Section
In this section, we define different constants. The keyword define is used in this part.
#define PI=3.14
Programming in C GOPIKA S, KJC
9
10. Global Declaration Section
This part of the code is the part where the global variables are declared. All the global variable used are
declared in this part. The user-defined functions are also declared in this part of the code.
float area(float r);
int a=7;
Main Function Section
Every C-programs needs to have the main function. Each main function contains 2 parts. A declaration part
and an Execution part. The declaration part is the part where all the variables are declared. The execution
begins with the curly brackets and ends with the curly close bracket. Both the declaration and execution
are inside the curly braces.
int main(void)
{
int a=10;
printf(" %d", a);
return 0;
}
Moving on to the next bit of this basic structure of a C program article,
Programming in C GOPIKA S, KJC
10
11. Sample Program
The C program here will find the area of a circle using a user-defined
and a global variable pi holding the value of pi
Programming in C GOPIKA S, KJC
// description: a program to calculate area of circle
// user enters the radius
#include<stdio.h>//link section
#define pi 3.14;//definition section
float area(float r);//global declaration
int main()//main function
{
float r;
printf(" Enter the radius:n");
scanf("%f",&r);
printf("the area is: %f",area(r));
return 0;
}
float area(float r)
{
return pi * r * r; //sub program
}
11