Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Class notes c language

Rating
-
Sold
-
Pages
114
Uploaded on
20-03-2023
Written in
2022/2023

The C language is very important and basci part of computer language .

Institution
Course

Content preview

Qspiders Campus Connect v1.0.0

Chapter 1 - Introduction

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.

The Unix operating system and virtually all Unix applications are written in the C language.
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.

1.1 Facts about C

• C was invented to write an operating system called UNIX.
• C is a successor of B language which was introduced around 1970
• The language was formalized in 1988 by the American National Standard Institute
(ANSI).
• By 1973 UNIX OS almost totally written in C.
• Today C is the most widely used System Programming Language.
• Most of the state of the art software have been implemented using C

1.2 Why to use C?

C was initially used for system development work, in particular the programs that make-up
the operating system. C was adoped as a system development language because it produces
code that runs nearly as fast as code written in assembly language. Some examples of the use
of C might be:

• Network Drivers
• Modern Programs
• Data Bases
• Language Interpreters
• Utilities

1.3. C Program File

All the C programs are writen into text files with extension ".c" for example hello.c. You can
use "vi" editor to write your C program into a file.




Vishal C Vanaki 1|Page

,Qspiders Campus Connect v1.0.0

1.4. C Compilers

When you write any program in C language then to run that program you need to compile
that program using a C Compiler which converts your program into a language
understandable by a computer. This is called machine language (ie. binary format). So before
proceeding, make sure you have C Compiler available at your computer. It comes alongwith
all flavors of Unix and Linux.

If you are working over Unix or Linux then you can type gcc -v or cc -v and check the result.
You can ask your system administrator or you can take help from anyone to identify an
available C Compiler at your computer.
1.5. Execution flow of C program

Source File
(.c extension)



Preprocessor


Extended
Source code


Compiler


Assembly code
(.asm file)


Assembler



Library Object Object code
code (.obj file)


Linker




Executable file
(.exe file)




Vishal C Vanaki 2|Page

,Qspiders Campus Connect v1.0.0

When we execute a C program these are steps that take place.
To execute the c program in Turbo C. press CTRL+F9.
1) The source code will be submitted to the preprocessor. Preprocessor is a software and part
of compiler which extends the source code by adding prototypes of pre-defined functions,
removing comments, replacing macros with its definition, etc.
2) The extended source code will then be submitted to the compiler, which intern generates
the assembly code (.asm).
3) This .asm file will be given as the input to the assembler which generates the object code(
machine readable- .obj file).
4) This object code and the library object codes (object codes of predefined function) will be
linked by the Linker. Then it generates executable file (.exe)
1.6. Syntax of C program
Different programming languages have their own format of coding. The basic components of
a C program are:

• Main()

• A pair of curly braces {,}

• Declarations and statements.

• User-defined functions.
The complete structure of a C program is shown below


Preprocessor_statements
Global_declarations;
main( )
{
Local_declarations;
statements;
}
User_defined_function


Preprocessor statements
These statements begin with # symbol, and are also called the preprocessor directives. These
statements direct the C preprocessor to include header files and also symbolic constants into a
C program.


Vishal C Vanaki 3|Page

, Qspiders Campus Connect v1.0.0

Some of preprocessor statements are given below
#include <stdio.h> : for the standard input/output functions
#include “Test.h” : for file inclusion of header file Test.
#define NULL 0 : for defining symbolic constant, NULL=0
Global Declarations
Variables or functions whose existence is known in the main( ) function and other user
defined functions, are called the global variables (of functions) and their declarations are
called the global declarations. This declaration should be made before main( ) as shown
above.
The main( ) function
As the name itself indicates, this is the main function of every C program. Execution of a C
program starts with main( ). No C program is executed without the main( ) function. The
function main( ) should be written in lower case letters and should not be terminated by a
semicolon. It calls other library functions and user defined functions. There must be one and
only one main( ) function in every C program.
Braces
Every C program uses a pair of curly braces ({,}). The left barce indicates the beginning of
the main() function. On the other hand, the right brace indicates the end of the main()
function. The braces can also be used to indicate the beginning and end of user-defined
functions and the compound statements.
Local declarations
The declaration is a part of the C program where all the variables, arrays, functions etc. used
in the C program are declared and may be initialized with their basic data types.
Statements
These are instructions to the computer to perform some specific operations.
User-defined functions
These are sub programs. The user-defined function contains a set of statements to perform a
specific task.




Vishal C Vanaki 4|Page

Written for

Course

Document information

Uploaded on
March 20, 2023
Number of pages
114
Written in
2022/2023
Type
Class notes
Professor(s)
Ram
Contains
All classes

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
050rameshm

Get to know the seller

Seller avatar
050rameshm Government school
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions