Journal Assignment No 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Assignment No 1.

1. Write a note on History of C language.


2. What are features of C language?
3.Explain structure of C program.
4. Write a note on Variables and keywords of c language
5. What is C and.Explain how C Program is executed?.
Solutions:

1. Write a note on History of C language .


History of C :

Year of
Language Name Developed By
Establishment
1960 ALGOL-60 Cambridge University
CPL (Combined Programming
1963 Cambridge University
Language)
BCPL (Basic Combined Martin Richard at
1967
Programming Language) Cambridge University
Ken Thompson at AT & T's
1970 B
Bell Laboratories.
Dennis Ritchie at AT & T'
1972 C
Bell Laboratory.

The development of C was a cause of evolution of programming languages like Algol 60, CPL
(Combined Programming Langauge), BCPL (Basic Combined Programming Language) and B.

• Algol-60 : (1963) :
ALGOL is an acronym for Algorithmic Language. It was the first structured procedural
programming language, developed in the late 1950s and once widely used in Europe. But it
was too abstract and too general structured langauage.
• CPL : (1963) :
CPL is an acronym for Combined Programming Language. It was developed at Cambridge
University.
• BCPL : (1967) :
BCPL is an acronym for Basic Combined Programming Language. It was developed by Martin
Richards at Cambridge University in 1967. BCPL was not so powerful. So, it was failed.
• B : (1970) :
B language was developed by Ken Thompson at AT & T Bell Laboratories in 1970. It was
machine dependent. So, it leads to specific problems.
• C : (1972) :
'C' Programming Langauage was developed by Dennis Ritchie at AT & T Bell Laboratories in
1972. This is general purpose, compiled, structured programming langauage. Dennis Ritchie
studied the BCPL, then improved and named it as 'C' which is the second letter of BCPL

2. What are features of C language?

C has been used successfully for every type of programming problem imaginable from
operating systems to spreadsheets to expert systems - and efficientcompilers are
available for machines ranging in power from the Apple Macintosh to
the Cray supercomputers. The largest measure of C's success seems to be based on
purely practical considerations:

1. the portability of the compiler;


2. the standard library concept;
3. a powerful and varied repertoire of operators;
4. an Easy syntax;
5. ready access to the hardware when needed;
6. and the ease with which applications can be optimised by hand-coding isolated
procedures

C is often called a "Middle Level" programming language. This is not a reflection


on its lack of programming power but more a reflection on its capability to access the
system's low level functions. Most high-level languages (e.g. Fortran) provides
everything the programmer might want to do already built into the language. A low
level language (e.g. assembler) provides nothing other than access to the machines basic
instruction set. A middle level language, such as C, probably doesn't supply all the
constructs found in high-languages - but it provides you with all the building blocks that
you will need to produce the results you want!

3. Explain structure of C program.

Structure of C Program
The basic structure of C program is as follow:

Document Section
Links Section (File)
Definition Section
Global variable declaration Section
void main()
{
Variable declaration section
Function declaration section
executable statements;
}
Function definition 1
---------------------
---------------------
Function definition n
where,
Document Section : It consists of set of comment lines which include name of a program, author
name, creation date and other information.
Links Section (File) : It is used to link the required system libraries or header files to excute a
program.
Definition Section : It is used to define or set values to variables.
Global variable declaration Section : It is used to declare global or public variable.
void main() : Used to start of actual C program. It includes two parts as declaration part and
executable part.
Variable declaration section : Used to declare private variable.
Function declaration section : Used to declare functions of program from which we get required
output.
Then, executable statements are placed for execution.
Function definition section : Used to define functions which are to be called from main().

4. Write a note on Variables and keywords of c language

Character Set :
A character refers to the digit, alphabet or special symbol used to data represetation.
1. Alphabets : A-Z, a-z
2. Digits : 0-9
3. Special Characters : ~!@#$%^&*()_+{}[]-<>,./?\|:;"'
4. White Spaces : Horizontal tab, Carriage return, New line, form feed

Identifier :

Identifier is the name of a variable that is made up from combination of alphabets, digits and
underscore.

Variable :

It is a data name which is used to store data and may change during program execution. It is
opposite to constant. Variable name is a name given to memory cells location of a computer where
data is stored.
* Rules for varibales:

• First character should be letter or alphabet.


• Keywords are not allowed to use as a variable name.
• White space is not allowed.
• C is case sensitive i.e. UPPER and lower case are significant.
• Only underscore, special symbol is allowed between two characters.
• The length of indentifier may be upto 31 characters but only only the first 8 characters are
significant by compiler.
• (Note: Some compilers allow variable names whose length may be upto 247 characters.
But, it is recommended to use maximum 31 characters in variable name. Large variable
name leads to occur errors.)

Keywords :

Keywords are the system defined identifiers.


All keywords have fixed meanings that do not change.
White spaces are not allowed in keywords.
Keyword may not be used as an indentifier.
It is strongly recommended that keywords should be in lower case letters.
There are totally 32(Thirty Two) keywords used in a C programming.
int float double long

short signed unsigned const


if else switch break

default do while for

register extern static struct

typedef enum return sizeof

goto union auto case

void char continue volatile

Escape Sequence Characters (Backslash Character Constants) in C:


C supports some special escape sequence characters that are used to do special tasks.
These are also called as 'Backslash characters'.
Some of the escape sequence characters are as follow:

Character Constant Meaning

\n New line (Line break)

\b Backspace

\t Horizontal Tab

\f Form feed

\a Alert (alerts a bell)

\r Carriage Return

\v Vertical Tab

\0 Null

5. What is C ? and Explain how C Program is executed?

WHAT IS C ?
C language is a general purpose and structured pragramming langauge developed by 'Dennis
Ritchie' at AT &T's Bell Laboratories in the 1972s in USA.
It is also called as 'Procedure oriented programming language.'
C is not specially designed for specific applications areas like COBOL (Common Business-Oriented
Language) or FORTRAN (Formula Translation). It is well suited for business and scietific
applications. It has some various features like control structures, looping statements, arrays,
macros required for these applications.
The C language has following numorous features as:
• Portability
• Flexibility
• Effectiveness and efficiency
• Reliability
• Interactivity

Execution of C Program :
C program executes in following 4 (four steps).

1. Creating a program :
An editor like notepad or wordpad is used to create a C program. This file contains a source
code which consists of executable code. The file should be saved as '*.c' extension only.
2. Compiling the program :
The next step is to compile the program. The code is compiled by using compiler. Compiler
converts executable code to binary code i.e. object code.
3. Linking a program to library :
The object code of a program is linked with libraries that are needed for execution of a
program. The linker is used to link the program with libraries. It creates a file
with '*.exe' extension.
4. Execution of program :
The final executable file is then run by dos command prompt or by any other software.

You might also like