A program structure of a Borland C++

Слайд 2

A structure of a program

A program in C++ programming language consists

A structure of a program A program in C++ programming language consists
of functions, descriptions and directives.
One of the functions should have name main. The execution of the program begins with the first statement of this function.
The simplest definition of a function has the following format:
return_type name_of_a_function ([parameters])
{a body of a function ;}
For example,
void main () //void is a return type main is the name of a program
{
cin<}

Слайд 3

Input/Output functions

There is no built-in input/output functions in C++ programming language. It

Input/Output functions There is no built-in input/output functions in C++ programming language.
is implemented using subroutines, types and objects contained in standard libraries:
ANSI С
C++ < iostream.h >

Слайд 4

Basic I/O functions in a C style:
int scanf (const char* format...) //input
printf(const

Basic I/O functions in a C style: int scanf (const char* format...)
char* format...) //output
They perform formatted input and output of an arbitrary number of values in accordance with the format string.
The format string contains characters that are copied to the stream (on the screen) when being output, or are requested from the stream (from the keyboard) upon input, and conversion specifications starting with the % character, which are replaced with specific values upon input and output .

Input/Output functions

Слайд 5

Example

#include
int main()
{ int i;
printf(“Enter number\n"); scanf("%d", &i);
printf(“You‘ve entered

Example #include int main() { int i; printf(“Enter number\n"); scanf("%d", &i); printf(“You‘ve
a number%d, thanks!", i);
}

Слайд 6

And here is what the same program looks like using the BORLAND

And here is what the same program looks like using the BORLAND
C ++ class library
#include
int main()
{ int i;
cout << “Enter number\n";
cin >> i;
cout << “You’ve entered a number “<< i << ", thanks!";
}

Input/Output functions

Слайд 7

Basic data types in BORLAND C++:

Basic data types in BORLAND C++:

Слайд 8

Named constants

A named constant is a constant that has a name. A

Named constants A named constant is a constant that has a name.
named constant is exactly like a variable, except that its value is set at compile time (by initializing it) and CANNOT change at runtime.
Declaring a named constant is a pointer to the compiler to replace (in the entire text – in a program) this identifier with a constant value .
Constants are added with a keyword const:
const type name_of_a_constant = value;
For example:
const float Pi = 3.14159;
For integer constants, the type can be omitted. The type must be specified for all other constants.
For example, the next definition
const Pi = 3,14159;
assign a value 3 to the constant Pi.

Слайд 9

Declaration of variables

The declaration of a variable has the form:
type list_of_identifiers;

Declaration of variables The declaration of a variable has the form: type

A list of identifiers may consist of variable identifiers, separated by commas.
For example: int x1, x2;
Simultaneously with the declaration, some or all of the variables can be initialized.
For example :
int xl=1, х2=2;
The declaration of variables can be a separate operator or be done inside of such operators, as, for example, a cycle operator:
for (int i=0; i<10; i++)
Имя файла: A-program-structure-of-a-Borland-C++.pptx
Количество просмотров: 24
Количество скачиваний: 0