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 programming

Rating
-
Sold
-
Pages
82
Uploaded on
11-07-2023
Written in
2022/2023

Practical C programming summarized class notes.

Institution
Course

Content preview

INTRODUCTION C PROGRAMMING

C is a powerful general purpose and most popular computer programming language. It
was developed in the 1972’s by Dennis M. Ritche at Bell Telephone laboratories (AT& T
Bell Labs). C was extensively used in its development C is an outgrowth of BCPL (Basic
combined Programming Language) developed by Martin Richards University.


C is often called a middle-level computer language, because it has the features of both
high-level languages, such as BASIC, PASCAL etc., and low-level languages such as
assembly language.


C is highly portable i.e., Software written for one computer can be run on another
computer. C language is well suited for structured programming. An important feature of
‘C’ is its ability to extend itself. A C program is basically a collection of functions. It
encourages us to write out own functions and add to the C library. Also C is modular, i.e.,
a unit of task can be performed by a single function and this unit of task can be reutilized
when needed. The large number of functions makes programming task simple.


STRUTURE OF A ‘C’ PROGRAM:

C programs consist of one or more functions. Each function performs a specific task. A
function is a group of sequences of statements that are together. And it is similar to
subprograms (or subroutines) in other high-level languages like Pascal.


Every C program starts with a function called main(). This is the place where program
execution begins. Hence, there should be main() function in every program. The
functions are building blocks of C program. Each function has a name and a list of
parameters ( or arguments).




1
C Programming Lecture Notes By: Kaba Daniel

,Documentation section
Linkage section
Definition section optional
Global declaration section


main ()
{
Declaration part
Execution part / statement part
}
Sub program section
Or optional
User defined section


Documentation section:
This section group of comments that explains about program name, purpose of the
program, program logic, programmer name, date of written program etc. Comments can
be included anywhere into the program. Comments are enclosed between /* and */.
Linkage Section:
It is the pre -processing directive operation section under this we can include the header
files with the # include <header file name. h>
Or
# include “header file name. h”
Whenever we are using standard functions into the main program those are referred into
the header files. When we included header file. Otherwise it gives error message header
file inclusion error
# include < stdio. h> or # include < graphic. h>
Definition section:
It is also the pre-processing directive operation. Under this we can define the symbolic
constant with the # define identifier data.
Example: #define


2
C Programming Lecture Notes By: Kaba Daniel

,These symbolic constant calls as macros. These macros are global.
Global declaration section:
Under this section we can declared the global variables. These variables can be used in
main program or other user defined function without declaration.
main():
main is a standard function to every program. Without main function program could not
process. It is compulsory for every program.
{ (left brace):
It indicates the beginning of the main. It is also compulsory.
Declaration part:
Whatever the variables, constants, array etc. we are going to be used into the statement
part those thing should be declared along with their storage class and type and identifier
name.
The syntax follows:


Storage Class data type variables
(identifiers)
Separate by a comma.
Example: auto int a,b,c;
Extern int x,y,z;
} (right brace):
It indicates the ending of the program it is also compulsory.
Subprograms:
Here we can write the user define sub-programs when ever we are facing repetitive task
then we can write user defined function. We can write any number of sub programs there
is no limit.

The following is a simple C program that prints a message on the screen.
# include <stdio.h>
/* A simple program for printing a message */
main()


3
C Programming Lecture Notes By: Kaba Daniel

, {
printf( “ hello , this is a C program.”);
}

The first line

# include <stdio.h>
Tells the compiler to read the file stdio.h and include its contents in this file. stdio.h, one
of header files, contain the information about input output functions. The next line is a
comment line Comments in the C program are optional and may appear anywhere in a C
program. Comments are enclosed between /* and */.
main() is the start of the main program. The word main is followed by a pair of ordinary
parenthesis (), which indicates that main is also a function. The left brace { represents the
beginning of the function where as the right brace } represents the end of the function. It
means, the braces enclose the body of function. In this program, the body consists of only
one statement, the one beginning with printf. The printf() function is causes its
arguments to printed on the computer screen. The closing (right) brace of the main
function is the logical end of the program.
The following are some of rules to write C programs.

i. All C statements must end with semicolon.
ii. C is case-sensitive. That is upper case and lower case characters are different.
Generally the statements are typed in lower case.
iii. A C statement can be written in one line or it can split into multiple lines.
iv. Braces must always match upon pairs, i.e., every opening brace { must have a
matching closing brace }.
v. No restriction in using blank spaces or blank lines that separates different words
or different parts of program. Blank spaces improve the readability of the
statements. But blank spaces are not allowed within a variable, constant or
keyword.
vi. Comments cannot be nested. For example,
/* A simple ‘C’ program, /* it prints a message */ */
is not valid.

4
C Programming Lecture Notes By: Kaba Daniel

Written for

Institution
Course

Document information

Uploaded on
July 11, 2023
Number of pages
82
Written in
2022/2023
Type
Class notes
Professor(s)
Professor kerry
Contains
All classes

Subjects

$15.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
Kabadan

Get to know the seller

Seller avatar
Kabadan Melbourne
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
8 year
Number of followers
0
Documents
3
Last sold
-
Summary study and exam notes

The notes are well summarized to quick understanding of concepts in computer science, Information Technology and programming.

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