answersLogoWhite

0

Functions have several purposes. Every program must have at least one global function named main. Although it is possible to write entire programs using this one function, this is only practical with extremely trivial applications, such as the "Hello World" application:

int main()

{

cout << "Hello world!";

}

As programs become more and more complex, however, we need to break the program down into much simpler problems, such that our main function actually does very little work. Typically, the main function does nothing more than call a function to process the command line arguments (and act upon them), wrapping that call in a catch-all exception handler.

The command line processing function itself will invoke an appropriate function according to the command line arguments, and thus becomes an elaborate switch statement.

Complex functions are difficult to read and maintain, but can be simplified by separating the code into a series of function calls, such that each function's name essentially describes what it does. Thus programs become self-documenting.

In C++, classes would be useless without functions (or methods as they are known).

User Avatar

Wiki User

10y ago

What else can I help you with?

Related Questions

What c plus plus program must be saved in a text with the extension cpp?

The .cpp extension is merely conventional; it is not required by the C++ standard. You can actually use any file extension you wish.


What is extension in c programming?

for c language it is .c and for c++ it is .cpp


How the c and cpp extension files can be retrived using FIND command in Linux?

find . -iname '*.c' -o -iname '*.cpp'


What is the easiest way to convert a CPP api to a flat C api?

Oh, dude, converting a CPP API to a flat C API? That's like asking how to turn a sports car into a go-kart. You basically just strip away all the fancy features, bells, and whistles of C++, and leave it with the bare minimum in C. It's like going from a gourmet meal to a plain ol' PB&amp;J sandwich. Just take out the C++ stuff and simplify it down to C - easy peasy, lemon squeezy.


Why the extension cpp of c?

The extension of a file containing a C program can be any extension, so long as the compiler or platform can infer the proper rules to build it. Commonly, for C programs, the extension is .c, so myfile.c would be a C program. The term cpp is not a designation for C++. It means C Program Precompiler, and it is the normal way to build one or more C programs into an executable. Over the years, cpp has evolved into being able to handle all sorts of languages. C++ is one of them. Typical extensions for C++ programs are .cc, .cpp, and .cxx.


How do you Open a text file as C plus plus source code?

All C++ source code is is a text file with the .cpp extension. So if you save your code as *****.cpp then it is automatically C++ source code.


Will particular C program be compatible for both g c c and DEV Cpp compiler?

That is possible. Try it.


Why is cpp or c platform dependent?

Different architecture on different platforms.


What year was Cpp released to the public?

C++ first appeared in 1983.


Major advantage in cpp compared to c?

The major advantage of C++ over C is the Object Oriented Programming compatibility in C++.


Is cpp complete oops?

No, C++ is not a strict OOP language as like Java and C#. C++ supports all OOPS concept like Encapsulation, Polymorphism, Inheritance etc. But C++ provides a way to expose the private data to outside world using friend functions, which is a violation of OOPS.


Major difference between java and cpp?

CPP typically stands for the C PreProcessor, which does macro expansion on C source code. What I suspect you want to know are the differences between C++ and Java. See the links below for more information on that topic.