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

Unit 2 Lect 1 Program Structure

The document discusses the structure of a C program. It explains that a typical C program consists of six sections: preprocessor directives, comments, header files, functions, variable declarations, and code. It provides an example C program with a main function that uses printf to output "Hello, World!" and returns 0. The document describes each part of the example program and explains features of C like comments, header files, and the main function.

Uploaded by

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

Unit 2 Lect 1 Program Structure

The document discusses the structure of a C program. It explains that a typical C program consists of six sections: preprocessor directives, comments, header files, functions, variable declarations, and code. It provides an example C program with a main function that uses printf to output "Hello, World!" and returns 0. The document describes each part of the example program and explains features of C like comments, header files, and the main function.

Uploaded by

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

CAP 172

PROGRAMMING METHODOLOGY

UNIT- 2
LECTURE - 1
Recap Quiz
Q. _______ symbol denotes in flowchart, to
perform input and output operations.

a)Rectangle
b)Oval
c)Connector
d)Parallelogram
POLL

Q. The procedural oriented and object oriented


programming languages fall under ______

a)Declarative Programming
b)Imperative Programming
Today We will discuss:
• Programming Language

• C Program Structure

• Character Set
Programming language?
• Programming Language is
– A tool for instructing machines.
– A means of communicating between programmers.
– used to create programs that implement specific
algorithms.
• A programming language is a formal language which
comprises a set of instructions used to produce various kinds
of output.
About C
• C is a procedural programming language.
• It was initially developed by Dennis Ritchie
between 1969 and 1973.
• C language is case sensitive.
Features of C language
C Program Structure
A typical C program may be divided into six different sections
Sample Program
• Let us take a look at the various parts of the above program −
• The first line of the program #include <stdio.h> is a preprocessor command, which
tells a C compiler to include stdio.h file before going to actual compilation.
• The next line int main() is the main function where the program execution begins.
• The next line /*...*/ will be ignored by the compiler and it has been put to add
additional comments in the program. So such lines are called comments in the
program.
• The next line printf(...) is another function available in C which causes the
message "Hello, World!" to be displayed on the screen.
• The next line return 0; terminates the main() function and returns the value 0.
Structure of C program
Comments

• Two forward slashes ‘ // ’ (double forward


slashes), are used to write single line comment
• The next combination ‘ /*……..*/ ’ (forward slash
with asterisk) is used for commenting multiple
lines
• These comments are not being executed by
compiler
Header files
The next two lines are command for including header files

These two lines must be included in every C program


stdio.h: standard input output header file for
functions printf(),scanf(),... and so on
conio.h: console input output header file for
functions getch()…. and so on

Here ‘ # ‘ is called preprocessor directive


Function
main() as special function, execution starts from here
A program must have a single main() function

A program without main() function wont work


main() function will call other functions

You might also like