0% found this document useful (0 votes)
63 views22 pages

Basic Parts of C Programming

The document discusses the basic parts of C++ programming including header files, the #include directive, main body, main function, syntax, reserved words, variable declaration, data types, statements, and looping statements. Header files declare functions and prototypes used for input/output and math. The #include directive includes other source files. The main body is where program execution begins. The main function performs the principal program function repeatedly.

Uploaded by

Jozel Valenzuela
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
63 views22 pages

Basic Parts of C Programming

The document discusses the basic parts of C++ programming including header files, the #include directive, main body, main function, syntax, reserved words, variable declaration, data types, statements, and looping statements. Header files declare functions and prototypes used for input/output and math. The #include directive includes other source files. The main body is where program execution begins. The main function performs the principal program function repeatedly.

Uploaded by

Jozel Valenzuela
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 22

BASIC PARTS OF C++ PROGRAMMING

HEADER FILES

• conio.h – declares various functions used in calling DOS console I/O


• dos.h – defines various constants and gives declaration needed for DOS 8086
specific calls
• float.h – contains parameters for floating point routines
• graphics.h – declares prototypes for the graphic functions
• math.h – declares prototypes for math functions
• mem.h – memory manipulation functions (also define string.h)
• process.h – contains structures and declarations for exec function
• stdio.h – defines types and macros needed for standard I/O
• stdlib.h – declares common routines conversion, sorting, and others
• string.h – declares several string manipulation and memory
manipulation
• iostream is
a header file that contains functions for input/output
operations (cin and cout).
# INCLUDE LIBRARY

• The #include preprocessor directive instructs the


compiler to include another source file with one that
has the #include directive on it.
MAIN BODY

• This refers to the set of statements in a computer


program at which the execution of the program
begins and from which the execution branches to
the subroutines of the program.
MAIN FUNCTION

• This is the main body of a program that performs


the principal function of a program over and over
until termination is somehow signaled.
SYNTAX

- Rules govern the structure of commands, statements or


instructions, content.

main()
{
….statement
RESERVED WORD

• This is a fixed function and cannot be used for any


purposes. It cannot be used for naming files,
variables, or other user-named objects.
EXAMPLES

• auto break case char


• const continue default do
• int long register return
• short signed sizeof static
• struct switch typedef union
• unsigned void while double
• else enum extern float
• for goto if else
MESSAGE WINDOW

• It lies beneath the edit window and used to display


various compiler or linker messages
VARIABLE DECLARATION

• This refers to the named area in memory that stores a


value or string assigned to that variable. It is named
storage location capable of containing a certain type of
data that can be modified during program execution.
• Global variable, local variable
RULES IN NAMING CONVENTION
1. A Variable name consists of any combination of alphabets, digits and
underscores. Some compiler allows variable names whole length could be up to
247 characters. Still it would be safer to stick to the rule of 31 characters.
2. Please avoid creating long variable name as it adds to your typing effort.
3. The first character of the variable name must either be alphabet or underscore.
It should not start with the digit.

4. No commas and blanks are allowed in the variable name.

5. No special symbols other than underscore are allowed in the variable name.
GLOBAL VS LOCAL VARIABLE
DATA TYPE

• This is a definition of a set of data that specifies the


possible range of values of the set, the operations that can
be performed on the values, and the way in which the
values are stored in memory. Knowing the type of data
enables the computer to manipulate it appropriately.
DATA TYPES

Data type Control String Description Example


char “%c” Used for outputting letter ‘w’, ‘y’
or symbol
char “%s” Used for outputting two “Melo’, “P102”
or more letters or
symbols
Int “%d” Used for outputting 8, 12, -5
whole numbers
Float “%f” Used for number with 8.12, 16.09
decimal
Double “%f” Used for outputting 567777, 6889899.78
larger number with or
without decimal
STATEMENTS IN C

Simple Statement - The simplest kind of statement in C is an expression


(followed by a semicolon, the terminator for all simple statements). Its value is
computed and discarded
COMPOUND STATEMENTS
•Conditional - these are compound statements
that test some condition and execute one or another
block depending on the outcome of the condition.
IF/ELSE
COMPOUND…

• Switch
LOOPING STATEMENT

• While loop – A while loop tests if a condition is true and if so executes its
body. It then tests the condition is true again, and keeps executing the body as
long as it is
LOOPING STATEMENT

• The Do While is like while except the test is done at the end of the loop
instead of the beginning. This means the body of the loop is always executed
at least once
LOOPING STATEMENT

• The For loop is used when a loop iterates over a sequence of values stored in
some variable. Argument has three expressions: 1st, initialize the variable and
is called once when the statement is first reached, 2nd, to test to see if the
body of the loop should be executed, 3rd , sets the variable to its next value

You might also like