0% found this document useful (0 votes)
4 views

Unit - 1 CP (Lecture 4)

Uploaded by

Neeraj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Unit - 1 CP (Lecture 4)

Uploaded by

Neeraj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

University Institute Of Computing

Bachelor of Computer Applications


Subject Name: Computer Programming
Code:20CAT111

1
Topics to be Covered
• Structure of C Program
• Comments
• Header files
• Preprocessor directives.

Fig. 4.1 Structure of C program [1]


2
Structure of C
• All C programs are having sections/parts which are mentioned below:

1. Documentation section
2. Link Section
3. Definition Section
4. Global declaration section
5. Function prototype declaration section
6. Main function
7. User defined function definition section

3
Structure of C Program Example

/* The following is a simple C program that prints a message on the screen. */


#include<stdio.h> // header file
#include<conio.h> // header file
void main()
{
clrscr();
printf(“Welcome to C”);
getch();
}

4
Rules to write C Program
1. All C statements must end with semicolon.
2. C is case-sensitive. That is, upper case and lower case characters are different.
Generally the statements are typed in lowercase.
3. Braces must always match upon pairs, i.e., every opening brace { must have a
matching closing brace }.
4. Every C program starts with void main() function.
5. Comments cannot be nested. For example,
/*Welcome to ‘C’,/*programming*/*/
A comment can be split into more than one line.

5
Basic Concepts
• Preprocessor directives
• Header files
• Character set
• Keywords
• Identifiers
• Variables
• Constants
• Operators
• Data types and their storage

6
Preprocessor Directive
• Before a C program is compiled in a compiler, source code is processed by a program
called pre-processor.

• Commands used in pre-processor are called pre-processor directives and they begin
with “#” symbol.

7
Preprocessor Directive

Fig. 4.2 Preprocessor Directive [2]


8
Header Files
• A file with extension .h which contains C function declarations and macro
definitions and to be shared between several source files.

• Request the use of a header file in program by including it, with the C pre-
processing directive #include which comes along with your compiler.

9
Header Files

FIG 4.3 : Header files [3]


10
Reference Image Link
[1]https
://www.wideskills.com/sites/default/files/subjects/C/Images/02/Structure%20of%20C%20Program.png

[2] https://www.wikitechy.com/tutorials/c-programming/preprocessor-directives

[3] https://codingsec.net/2016/09/every-library-file-function-c-programming/

11
Reference Books
• T1 E. Balaguruswamy, Programming in ANSI, McGraw-Hill Education,
• https://bookmart.online/shop/programming-in-ansi-c-8-e-balagurusamy-second-hand-book/?ut
m_source=Google%20Shopping&utm_campaign=test&utm_medium=cpc&utm_term=498

• R1 Byron S. Gottfried, Programming with C, McGraw-Hill (2nd Edition)


• https://www.amazon.com/Schaums-Outline-Programming-Byron-Gottfried/dp/0070240353/ref
=sr_1_1?dchild=1&keywords=%E2%80%A2+Programming+with+C%2C+Gottfried%2C+a
nd+McGraw-Hill.&qid=1593001561&s=books&sr=1-1

• R2 Brian W. Kernighan, Dennis M. Ritchie, The ANSI C Programming Language, Prentice-


Hall 2nd Edition.
• http://www2.cs.uregina.ca/~hilder/cs833/Other%20Reference%20Materials/The%20C
%20Programming%20Language.pdf

12
THANK YOU
For queries
Email:[email protected]

You might also like