Actual and Formal Arguments in C

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

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 have a Variable Number of Arguments in C?

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

ADTs and Black Boxes 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

Efficiency of Recursion vs Iteration in C

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

Difference Between Recursion and Iteration in C

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 Recursion with Example in C

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

Functions in C with Examples

This Tutorial Explains Functions in C with Example(s). What is Function in C? A function is a block of code that performs a specific task. Functions are often used to perform similar tasks on different data sets. There are two types of functions in C, user-defined functions and library functions. User-defined functions are the functions … Read more

advertisement

Which Function Comes as an Integral Component of 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 Parameters of 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
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.