C++ Arrays and functions

C++ Arrays and functions

C++ Arrays and functions

 Arrays in C++

The application of arrays in C++ is similar to that in C. The only exception is the way character arrays are initialized. When initializing a character array in ANSI C, the compiler will allow returns to declare the array size as the exact length of the string constant. For instance,
Char strings {4}= “xyz”;
Is valid in ANSI C. It assumes that the program of intends to leave out the null character 0 in the definition. But in C++, the size should be one larger than the number of characters in the string.
Char strings {4}= “xyz”;//O.K for C++

C++ Functions

A function is a subprogram that acts on that data and often returns a value. You’re already familiar with the one functions that every C++ program process:
int main(void).
Each functions r has its own name. When that name is encountered in a program, the execution of the program branches of the body of that function. When the function is finished, execution returns to the area of the program code from which it was called and the program continues on to the next line of code.
Like C, the C++ program is a collection of function. The example contains only one functions, main (). C++ is a free-from language. with a few exceptions, the compiler ignores carriage returns and white spaces. Like, the C++ statements terminate with semicolons.

Leave a Reply

Your email address will not be published.