answersLogoWhite

0

How do you write C program to call 5 functions in a line?

Updated: 8/18/2019
User Avatar

Wiki User

13y ago

Best Answer

example:

#include

static int INC (int val) { return val+1; }

int main (void) {

printf ("INC*5 (1) = %d\n",

INC (INC (INC (INC (INC (1))))));

return 0;

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write C program to call 5 functions in a line?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How write new line program in java?

\n


Write a java program to count the space from the given line?

.... String line = "This is example program with spaces"; String[] tokens = line.split(" "); System.out.println(tokens.length-1); .......


How do you call a function in GUI in matlab?

Just type it in the command line. That will call functions, scripts, load data (that are in the correct directory).


What are the in-line functions in cc?

In-line functions differ from normal functions by the way they are dealt with by the compiler. Normally, a function (or its code, more exactly) is stored once within the executable program. A call to this function then results in putting the parameters onto the stack and jumping to the start address of the function. When the function is finished, the stack is freed from the parameters and the program continues right after the point from where it has jumped to the function. For an in-line function, its code is stored at any place where it is called. This saves us from the administrative overhead (putting parameters etc. onto the stack and cleaning up at the end) and, thus, reduced computing time. On the other side it enlarges the eecutable.<br> This leads to some restrictions to inline-functions.


Write a program to implement a line using slope intercept formula?

lund lelo mooh mein


When you write a program that will run in a GUI environment as opposed to a command line environment?

Some syntax is different.


Write c programs to display 10 line biodata?

A C++ program can be used to write C programs that will display 10 lines of biodata. Many types of C programming can be written with a C++ program.


How can you call a function from other program to your program in c plus plus?

You cannot invoke external program functions directly if that's what you mean. In order for two program to communicate with each other you need some kind of marshalling system. Since the only entry point that is directly available is your main function you could use command line switches to invoke specific functions in your program, but you cannot return anything useful to the calling program other than an integer. The other downside is that you must load and unload your program with each call. If that is adequate for your needs then its certainly a solution, albeit an elegant one. A better approach is to make use of your operating system's message queue. This allows two separate programs to communicate with each other through their own message handlers. Thus program A can post a message instructing program B to invoke a certain function and the function can post a message back to program A with the result of that function. Of course both programs must be running, but there's nothing to stop program A from invoking program B with a command line switch containing program A's process ID, thus allowing program B to post a message to program A when it is ready to receive messages. Of course an altogether better approach would be to place all the shared functions in a dynamically linked library that either program can load and call just as if those functions were statically linked within the program itself. If the programs themselves need to communicate with each other, message queues can be used for that purpose, but shared functionality should be kept entirely separate wherever possible.


Why is there no horizontal-line test for functions?

there is no horizontal-line test for functions, because people do not do the test that is why !!!


What does a short line in front of the word program mean---- program?

blank program


What are non linear functions?

Functions that do not result in a line when graphed.


What is the purpose of having multiple functions if int main is where all execution occurs?

Although you could write an entire program in the global main function alone, non-trivial programs would be difficult to maintain, relying heavily upon user-comments. Functions allow us to separate our code into more easily maintained chunks and with well-named functions, complex code becomes largely self-documenting. By keeping our functions as small and as simple as possible (one or two statements at most), we can minimise the cost of making function calls through inline expansion and greatly reduce the amount of duplicate code we need to write. In a large and complex program, the global main function should simply parse the command line and then call the appropriate function(s). In C++, we also use the global main function as a catch-all exception handler.