Professional Documents
Culture Documents
Chapter: - 1 Introduction of „C ‟
Q. 1 Write a short note on history of C.
By 1960, number of computer languages had come into existence almost each for a
specific purpose. For Example: - COBOL (Common Business Oriented Language)
was being used for commercial Application, FORTRAN (Formula Transaction Language)
for engineering & scientific application and so on. At this stage people started thinking
for a general purpose language. Therefore, an International Committee was formed to
develop such a language. This committee comes out with a language called ALGOL-60.
However, ALGOL-60 never really become popular because it seemed too obstruct, too
general.
To reduce this abstractness and generality a new language called Combined
Programming Language (CPL) was developed at Cambridge University. However, CPL
turned out to be so big, having so many features, that it was hard to learn and difficult
to implement.
Basic Combined Programming Language (BCPL) was developed by Martin Richards at
Cambridge University aimed to solve this problem by bringing CPL down to its good
features. But unfortunately it turned out to be too less powerful and too specific.
Meanwhile, Ken Thompson has developed language „B‟ as a further simplification of
CPL at AT&T‟s Bell Labs. But like BCPL B too turned out to be very specific.
Dennis Ritchie inherited the features of B and BCPL in C, added some of his own and
developed the „C‟ language at AT&T Bell Laboratories of USA in 1972. Dennis Ritchie‟s
main achievement is the restoration of lost generality and still keeping it powerful.
To Standardize C, American National Standards Institute (ANSI) appointed a technical
committee. It later came to be known as ANSI C. Later it is standardized by ISO
Committee to form ISO and ANSI C.
Q. 2 What is „C‟?
„C‟ is a programming language developed at AT&T Bell Labs of USA in 1972.
It was designed and written by Dennis Ritchie.
„C‟ is a compatible language , because it can work on any platform(DOS/WINDOWS)
„C‟ is Middle Level Language, because it is the combination of Higher Level
Language (Problem Oriented Language) and Lower Level Language
(Assembly/Machine Level Language).
„C‟ supports both GUI (Graphical User Interface) and CLI (Command Line Interface)
environment.
„C‟ having high probability, it means it is working on different hardware platforms.
„C‟ is reliable because it contains necessary tools for solving user problems.
Execution time very fast with respect to other languages that‟s why „C‟ has better
efficiency.
„C‟ is a case-sensitive language
i.e. int a;
int A;
So, a and A both are different variables.
Q. 3 Write a short note on C Character Set.
Character Sets:
A, B, C,……..,Z
Alphabets
a, b, c,………,z
Digits 0, 1, 2,……….,9
Constants in C refer to fixed values that do not change the execution of program.
There are basically two types of constants namely:
1. Numeric Constants
2. Character Constants
Constants
Numeric Character
„C‟ supports basically Integer Constants, Real Constants and Character Constants.
1. Numeric Constant :
A. Integer Constant :-
RULES:
An integer constant must have at least one digit.
It must not have a decimal point.
It could be either positive or negative.
If no sign precedes an integer constant it is assumed to be positive.
No commas or blanks are allowed within an integer constant.
The allowable range for integer is -32768 to +32767.
Example of „int‟ constant
i.e. 3
325
45.5 -
10,000 -
40,000 much larger -
+32
-5
There are three types of integers namely Decimal, Octal, Hexa-Decimal.
B. Real Constant :-
The numbers containing fractional parts are as a Real Constant. It‟s also
called as a Floating Point Constant.
RULES
A Real Constant must have at least one digit.
It must have a decimal point.
It could be either positive or negative.
Default sign is positive.
Prepared by Mr. Pankaj M. Zalera 3
Programing In C [SMT. V.B. NANDOLA COMPUTER SCIECNE COLLEGE, BHACHA]
i.e. ‟A‟
„A‟ -
‟AB‟ -
‟a‟
‟=‟
„12‟ -
‟1‟
RULES:
A character constant is either a single alphabet, a single digit or a single
special symbol enclosed within single inverted commas. Both the
inverted commas should point to the left.
For Example:
‟A‟ is a valid character constant whereas „A” is not.
The maximum length of a single character constant can be 1 character.
Prepared by Mr. Pankaj M. Zalera 4
Programing In C [SMT. V.B. NANDOLA COMPUTER SCIECNE COLLEGE, BHACHA]
Q. 5 What are different type of variable in „C‟, and also discuss variable
naming rules?
Variable whose value constantly changing during the program execution.
Keywords can‟t be taken as a variable.
It is a temporary storage media for solving user‟s problem.
Variable have two types:
Variable
Example:-
#include<stdio.h>
#include<conio.h>
int a=15; //Global type, Class: External
void main()
{
int a=10; //Local type, Class: Internal
clrscr();
printf(“\n Value of a: %d”,a); //Local
printf(“\n Value of a: %d”,::a); //External
getch();
}
Output:-
Value of a: 10
Value of a: 15
RULES:
A variable name is any combination of 1 to 8 alphabets, digits or
underscores (_).
Prepared by Mr. Pankaj M. Zalera 5
Programing In C [SMT. V.B. NANDOLA COMPUTER SCIECNE COLLEGE, BHACHA]
Document Section:
Link Section:
Definition Section:
# include<stdio.h>
# define L 100;
void main()
{
int b,p;
clrscr();
printf(“\n Enter Breath”);
scanf(“%d”,&b);
p=2*( L + b);
printf(“\n Perameter Is : %d”,p);
getch();
}
The definition section defines all symbolic constants.
Definition is considered as pre-processing section because before
compiling main function processor compiles definition section first.
With Definition section symbolic constant is created (L).
Inside the main function when symbol comes, compiler replaces its
value.
Global Declaration Section:-
1. Keywords:
3. Constants:
Constants in „C‟ refer to fixed values that do not change during the
execution of a program.
„C‟ supports basically Integers constants, Real constants and character
constants.
4. Strings:-
String is also considered as a part of character constants. A character
constant contains is either alphabet or digits or special symbols enclosed
within double inverted commas.
Prepared by Mr. Pankaj M. Zalera 9
Programing In C [SMT. V.B. NANDOLA COMPUTER SCIECNE COLLEGE, BHACHA]
5. Operators:-
„C‟ supports a rich set of operators. An operator is a symbol that tells the
computer to perform certain mathematical and logical manipulations.
There are eight types of operators in „C‟. They include:
A. Arithmetic
B. Relational
C. Logical
D. Assignment
E. Increment & Decrement
F. Conditional
G. Bitwise
H. Special
6. Special symbols:-
There are some of the special symbols in computer. We can use these
symbols in programming „C‟.
Ex.:
+ - * / { } ( ) [ ] ; : „ “ , . ? # etc.
2. Input/output Instruction
These instructions are used for string and displaying value.
e.g.:
scanf();
printf();
puts();
gets();
3. Arithmetic Instruction
To perform Addition, Subtraction, multiplication, Division this
instructions are used as operators.
e.g.:
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo Division
4. Conditional Instruction
For checking condition of instruction on this instructions are used.
e.g.:
if
if…..else
switch…..case
5. Control Instruction
To control the sequence of execution of various statement in a „C‟
program by using control instruction.
e.g.:
for()
while()
do…while()
Q. 10 Discuss the Hierarchy of Operations.
The order or priority or the precedence in which the arithmetic
statements is called as the Hierarchy of operations. The hierarchy of
operations while evaluating any arithmetic instructions in „C‟ can be
narrated as follow:
Advantages:-
1) „C‟ is a powerful & flexible language.
2) „C‟ is a considered as a portable language. Portable means „C‟ program
can be compiled on any platform (O.S. [DOS/WINDOWS]).
3) Maximum data type we can use in „C‟ language.
4) For the mathematical and string type operation, different library files are
available.
5) For creation of graphics library file is also available <graphics.h>.
6) We can create data file in „C‟ language.
7) For the execution of program very fast pointer type facility is available.
8) We can define structure and union in „C‟ language.
9) Maximum data types are available in „C‟ language.
Disadvantages:-
1) Perform, reading & understanding is difficult.
2) Whenever error create in program modification in the program is
difficult.
3) Usage of pointer is also difficult.