Prepared By : Uday Shah - HOD(IT)
Contact No : 7600044051
C PROGRAMMING HISTORY:
The C language is a structure oriented programming language, was
developed at Bell Laboratories in 1972 by Dennis Ritchie. C language features
were derived from an earlier language called “B” (Basic Combined Programming
Language – BCPL). C language was invented for implementing UNIX operating
system.
C PROGRAMMING BASICS:
Steps to be followed for any C program to create and get the
output are explained . This is common to all C programs and there is no
exception, whether its a very small C program or very large program. Structure
of a C program is defined by a set of rules called protocol, to be followed by
programmer while writing a C program.
C – PRINTF AND SCANF:
printf() and scanf() functions are inbuilt library functions in
C which are available in the C library by default. These functions are declared
and related macros are defined in “stdio.h” which is a header file. We have to
include “stdio.h” file as shown in below C program to make use of these
printf() and scanf() library functions.
C – DATA TYPES:
C data types are defined as the data storage format that a
variable can store a data to perform a specific operation. Data types are used
to define a variable before using in a program. Size of variable, const and
array are determined by data types. There are four data types in the C
language. They are.
C – DATA TYPES:
Types
|
Data Types
|
Basic data
types
|
int, char,
float, double
|
Enumeration
data type
|
Enum
|
Derived data
type
|
pointer,
array, structure, union
|
Void data
type
|
void
|
C – TOKENS AND KEYWORDS:
C tokens, Identifiers and Keywords are the basics in a C
program. All are explained in this page with definition and simple example
programs. C tokens are the basic building blocks in C language which are
constructed together to write a C program. Each program element in a C program
is given a name called identifiers.
C – CONSTANTS:
C Constants are also like normal variables. But, the only
difference is, their values can’t be modified by the program once they are
defined. Constants refer to fixed values. They are also called as literals.
Constants may be belonging to any of the data type.
C – VARIABLES:
C variable is a named location in a memory where a program can
manipulate the data. This location is used to hold the value of the variable.
The value of the C variable may get changed in the program. The C variable
might be belonging to any of the data types like int, float, char etc.
C – OPERATORS AND EXPRESSIONS:
The symbols which are used to perform logical and mathematical
operations in a C program are called C operators. These C operators join
individual constants and variables to form expressions. Operators, functions,
constants and variables are combined together to form expressions.
C – DECISION CONTROL STATEMENTS:
In decision control statements (C – if else and nested if),
group of statement is executed when the condition is true. If the
condition is false, then, else part statements are executed. In C programming,
there are 3 types of decision making control statements in C language. If
Statement, if else statement and nested
if statements.
C – LOOP CONTROL STATEMENTS:
Loop control statements in C programming are used to perform
looping operations until the given condition is true. Control comes out of the
loop statements once the condition becomes false. There are 3 types of loop
control statements in C language. For Loop, While Loop and Do while Loop.
C – CASE CONTROL STATEMENTS:
The statements which are used to execute only specific block of
statements in a series of blocks are called case control statements. There are
4 types of case control statements in C programming. They are 1) switch 2)
break 3) continue 4) goto.
C – TYPE QUALIFIERS:
The keywords which are used to modify the properties of a variable
are called type qualifiers. There are two types of qualifiers available in C
programming. They are 1) const 2) volatile. Constants are also like normal
variables.
C – STORAGE CLASS SPECIFIERS:
Storage class specifiers in C programming tell the compiler
where to store a variable, how to store the variable, what is the initial value
of the variable and the lifetime of the variable. There are 4 storage class
specifiers available in C language. Local , Global , Static and Register
C – ARRAY:
C Array is a collection of variables belongings to the same data
type. You can store group of data of the same data type in an array. There are
2 types of arrays in C programming. They are 1) One dimensional array 2)
Multidimensional array.
C – STRING:
C Strings are nothing but array of characters ended with null
character (‘\0’). This null character indicates the end of the string. In C
programming, strings are always enclosed by double quotes. Whereas, character
is enclosed by single quotes in C.
C – POINTER:
C Pointer is a variable that stores/points the address of the
other variable. C Pointer is used to allocate memory dynamically, i.e. at
run time. The variable might be any of the data types such as int, float, char,
double, short etc. Normal variable stores the value, whereas pointer variable
stores the address of the variable.
C – FUNCTIONS:
Functions in C programming are basic building blocks in a
program. All C programs are written using functions to improve re-usability,
understandability and to keep track of them. A large C program is divided into
basic building blocks called C function. C function contains set of
instructions enclosed by “{ }” which performs specific Task.
C – LIBRARY FUNCTIONS:
Library functions in C language are inbuilt functions which are
grouped together and placed in a common place called a library. Each library
function in C programming language performs a specific operation. We can make
use of these library functions to get the pre-defined output instead of writing
our own code to get those outputs.
C – COMMAND LINE ARGUMENTS:
main() function of a C program accepts arguments from command
line or from other shell scripts by following commands. They are 1. argc 2.
argv[]. In real time application, it will happen to pass arguments to the main
program itself. These arguments are passed to the main () function while
executing binary file from command line.