What are Actual and Formal Arguments in a C Function

This C Tutorial Explains Actual and Formal Arguments in a C Function with Example(s). Consider, for example, a C program below, /* * actual_formal_arg.c — program hinges on relationship between actual and * formal arguments */ #include <stdio.h> void even_odd(int);   int main(void) { int num, what;   printf("\nProgram determines a given integer is EVEN … Read more

advertisement

Explain Function Arguments in C Programming with Examples

This C Tutorial Explains Function Arguments in C Programming with Example(s). Let’s, first, try to understand why function arguments are required. Consider, for example, a C Program below: #include <stdio.h> void hahaha(void); /* function hahaha() declared here */   int main(void) { hahaha(); /* hahaha() is called in main() */ return 0; }   /* … Read more

advertisement

Can a Function in C Programming have Variable Number of Arguments?

Question: Can a Function in C Programming have Variable Number of Arguments? Answer: Of course! Functions in a C program can have variable number of arguments. let’s first explore a very familiar standard C library output function ‘printf()’ below, /* * fun_with_varible_arg1.c — program shows function takes variable number * of arguments */ #include <stdio.h> … Read more

advertisement

Explain Recursion in C Programming with Examples

This C Tutorial Explains the concept Recursion in C Programming with examples. C allows a function to call itself. This is called Recursion. Let’s see an example, void main(void) { main(); } What happens when the program is compiled and run, main() function’s type, here for ex., is void and it doesn’t take any arguments. … Read more

advertisement

What are ADTs and Black Boxes in Context with Functions in C?

This C Tutorial Explains ADTs and Black Boxes in Context with Functions in C. Many programmers like to think of a function as a “black box” defined in terms of the information that goes in (its input) and the value or action it produces (its output). What goes on inside the black box is not … Read more

advertisement

Which is more Efficient in C Programming – Recursion OR Iteration?

Question: Which is more Efficient in C Programming – Recursion OR Iteration? Answer: In general, recursion is slow, exhausting computer’s memory resources while iteration performs on the same variables and so is efficient. But recursion on the other hand, in some situations, offers convenient tool than iterations. Let’s take an example of a program below … Read more

advertisement

Is Recursion in C Different from Iteration Implemented Through Loops

Question: Is Recursion in C Different from Iteration Implemented Through Loops Answer: To understand the difference between Recursion and Iteration implemented through loops, let’s first consider a simple program, /* down_recur.c — program counts down ways */ #include <stdio.h> void countdown(int);   int main(void) { int num = 100; countdown(num);   return 0; }   … Read more

advertisement

Explain Functions in C with Examples

This C Tutorial Explains Different Components of a C Function with Example(s). ANSI C Standard specifies general syntax of any C function as: type function_name(formal_arguments) /* function definition header */ { statements; /*function body*/ return statement; } Like variables, every function also has a type, meaning that what type of value function returns to its … Read more

advertisement

Is Function an Integral Component of Every C Program?

Question: Is Function an Integral Component of Every C Program? Answer: Before we proceed to answer this, let’s look at the design, in its simplest form, of a C program, /* * sim_c_prog.c — program shows even simplest C program requires function * main() */ void main(void) { /* Nothing happens here! */ } When … Read more

advertisement

Can the Formal Parameters to a Function in C be Declared Static?

Question: Can the Formal Parameters to a Function in C be declared Static? Answer: Let’s first try a static variable to see how it behaves when function containing the variable is called more than once. For example, /* * behaviour_static_var_fun.c — program shows how static variable * behaves */ #include <stdio.h> void display_static_var(void); /* declaration … Read more

advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter